From 0e6380ac9ae3402ee8f4cfbd3658123587095d5b Mon Sep 17 00:00:00 2001 From: Camille Perin Date: Thu, 28 Jan 2021 11:55:22 +0100 Subject: [PATCH 001/194] Add VDSFile openoption --- java/CMakeLists.txt | 1 + java/cpp/src/OpenVDSJava.cpp | 14 +++++++ java/java/demo/CreateVDS.java | 4 ++ .../src/org/opengroup/openvds/OpenVDS.java | 7 ++++ .../opengroup/openvds/VDSFileOpenOptions.java | 42 +++++++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 java/java/demo/CreateVDS.java create mode 100644 java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 2525cc8a..bfd86991 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -37,6 +37,7 @@ set(JAVA_SOURCE_FILES java/src/org/opengroup/openvds/OpenVDS.java java/src/org/opengroup/openvds/QuantizingValueConverter_FloatToByte.java java/src/org/opengroup/openvds/VdsHandle.java + java/src/org/opengroup/openvds/VDSFileOpenOptions.java java/src/org/opengroup/openvds/VDSProduceStatus.java java/src/org/opengroup/openvds/VolumeDataAccessManager.java java/src/org/opengroup/openvds/VolumeDataAccessor.java diff --git a/java/cpp/src/OpenVDSJava.cpp b/java/cpp/src/OpenVDSJava.cpp index 52ece5b6..d4854289 100644 --- a/java/cpp/src/OpenVDSJava.cpp +++ b/java/cpp/src/OpenVDSJava.cpp @@ -86,6 +86,20 @@ jlong JNICALL Java_org_opengroup_openvds_OpenVDS_cpOpenGoogle return openVDSOrThrowJavaIOException(env, openOptions); } +/* + * Class: org_opengroup_openvds_OpenVDS + * Method: cpOpenVDSFile + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_OpenVDS_cpOpenVDSFile + (JNIEnv *env, jclass, jstring jfilepath) { + OpenVDS::VDSFileOpenOptions openOptions; + + openOptions.fileName = JStringToString(env, jfilepath); + + return openVDSOrThrowJavaIOException(env, openOptions); +} + /* * Class: org_opengroup_openvds_OpenVDS * Method: cpOpenAzurePresigned diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java new file mode 100644 index 00000000..eca900b2 --- /dev/null +++ b/java/java/demo/CreateVDS.java @@ -0,0 +1,4 @@ +package PACKAGE_NAME; + +public class CreateVDS { +} diff --git a/java/java/src/org/opengroup/openvds/OpenVDS.java b/java/java/src/org/opengroup/openvds/OpenVDS.java index 63e3a868..3a48f73c 100644 --- a/java/java/src/org/opengroup/openvds/OpenVDS.java +++ b/java/java/src/org/opengroup/openvds/OpenVDS.java @@ -31,6 +31,8 @@ public class OpenVDS extends VdsHandle{ private static native long cpOpenConnection(String url, String connectionString) throws IOException; + private static native long cpOpenVDSFile(String filePath) throws IOException; + private static native long cpCreateAzure(String pConnectionString, String pContainer, String pBlob, int pParallelismFactor, int pMaxExecutionTime, VolumeDataLayoutDescriptor ld, VolumeDataAxisDescriptor[] vda, @@ -83,6 +85,11 @@ public class OpenVDS extends VdsHandle{ if ("".equals(url)) throw new IllegalArgumentException("url can't be empty"); return new OpenVDS(cpOpenConnection(url, connectionString), true); } + + public static OpenVDS open(VDSFileOpenOptions o) throws IOException { + if (o == null) throw new IllegalArgumentException("open option can't be null"); + return new OpenVDS(cpOpenVDSFile(o.filePath), true); + } private static void validateCreateArguments(VolumeDataLayoutDescriptor ld, VolumeDataAxisDescriptor[] vda, VolumeDataChannelDescriptor[] vdc, diff --git a/java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java b/java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java new file mode 100644 index 00000000..9aacd0b9 --- /dev/null +++ b/java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java @@ -0,0 +1,42 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.openvds; + +/** + * Options for opening a VDS in Microsoft Azure cloud computing platform. + */ +public class VDSFileOpenOptions extends OpenOptions { + + public String filePath; + + /** + * Default constructor. + */ + public VDSFileOpenOptions() { + super(ConnectionType.File); + } + + /** + * Constructor. + * + * @param pFilePath the file path the VDS + */ + public VDSFileOpenOptions(String pFilePath) { + super(ConnectionType.File); + } +} -- GitLab From 7e3e94ded3ced63b53fca578d0eded09bc41a125 Mon Sep 17 00:00:00 2001 From: Camille Perin Date: Thu, 28 Jan 2021 15:01:31 +0100 Subject: [PATCH 002/194] fix file path --- java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java b/java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java index 9aacd0b9..d17c89ea 100644 --- a/java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java +++ b/java/java/src/org/opengroup/openvds/VDSFileOpenOptions.java @@ -38,5 +38,7 @@ public class VDSFileOpenOptions extends OpenOptions { */ public VDSFileOpenOptions(String pFilePath) { super(ConnectionType.File); + + this.filePath = pFilePath; } } -- GitLab From 95c6380283ab1bdfae4a1fe7db060fcb553ea73a Mon Sep 17 00:00:00 2001 From: Camille Perin Date: Mon, 15 Feb 2021 17:28:28 +0100 Subject: [PATCH 003/194] Progress --- java/cpp/src/OpenVDSJava.cpp | 15 + java/java/demo/CreateVDS.java | 160 +- java/java/demo/WriteDataDemo.java | 178 ++ .../src/org/opengroup/openvds/JniPointer.java | 2 +- .../src/org/opengroup/openvds/OpenVDS.java | 12 + .../openvds/VolumeDataAxisDescriptor.java | 8 + .../openvds/VolumeDataChannelDescriptor.java | 34 + .../openvds/VolumeDataLayoutDescriptor.java | 2 +- tools/CMakeLists.txt | 1 + tools/ScratchVDSFileCreate/CMakeLists.txt | 7 + tools/ScratchVDSFileCreate/VDSFileCreate.cpp | 227 ++ tools/ScratchVDSFileCreate/cxxopts.hpp | 2087 +++++++++++++++++ 12 files changed, 2730 insertions(+), 3 deletions(-) create mode 100644 java/java/demo/WriteDataDemo.java create mode 100644 tools/ScratchVDSFileCreate/CMakeLists.txt create mode 100644 tools/ScratchVDSFileCreate/VDSFileCreate.cpp create mode 100644 tools/ScratchVDSFileCreate/cxxopts.hpp diff --git a/java/cpp/src/OpenVDSJava.cpp b/java/cpp/src/OpenVDSJava.cpp index d4854289..7dd5eb5c 100644 --- a/java/cpp/src/OpenVDSJava.cpp +++ b/java/cpp/src/OpenVDSJava.cpp @@ -329,6 +329,21 @@ Java_org_opengroup_openvds_OpenVDS_cpCreateAzure(JNIEnv *env, jclass, jstring jC return createVDSOrThrowJavaIOException(env, openOptions, ld, vda, vdc, md); } +/* + * Class: org_opengroup_openvds_OpenVDS + * Method: cpCreateVDSFile + * Signature: (Ljava/lang/String;Lorg/opengroup/openvds/VolumeDataLayoutDescriptor;[Lorg/opengroup/openvds/VolumeDataAxisDescriptor;[Lorg/opengroup/openvds/VolumeDataChannelDescriptor;Lorg/opengroup/openvds/MetadataReadAccess;)J + */ +JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_OpenVDS_cpCreateVDSFile + (JNIEnv *env, jclass, jstring jVDSFilePath, + jobject ld, jobjectArray vda, jobjectArray vdc, jobject md){ + OpenVDS::VDSFileOpenOptions openOptions; + + openOptions.fileName = JStringToString(env, jVDSFilePath); + + return createVDSOrThrowJavaIOException(env, openOptions, ld, vda, vdc, md); +} + jlong JNICALL Java_org_opengroup_openvds_OpenVDS_cpCreateAws(JNIEnv *env, jclass, jstring jbucket, jstring jkey, jstring jregion, jstring jendpointoverhide, jstring jaccessKeyId, jstring jsecretKey, jstring jsessionToken, jstring jexpiration, diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index eca900b2..70fe6e8d 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -1,4 +1,162 @@ -package PACKAGE_NAME; +import org.opengroup.openvds.*; + +import java.util.List; public class CreateVDS { +/** + public static void main(String[] args) { + try { + process(args); + } catch (Throwable t) { + System.out.println(); + t.printStackTrace(); + } + } + + static void process(String[] args) throws Exception { + int samplesX = 1000; + int samplesY = 1000; + int samplesZ = 1000; + VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; + + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_64; + int negativeMargin = 4; + int positiveMargin = 4; + int brickSize2DMultiplier = 4; + VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.LOD_LEVELS_NONE; + //VolumeDataLayoutDescriptor.Options layoutOptions = VolumeDataLayoutDescriptor.Options.NONE; + VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, false,false,0); + + List axisDescriptors; + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "ms", 0.0f, + 4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "", + 1932.f, 2536.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 9985.f, + 10369.f)); + + List channelDescriptors; + float rangeMin = -0.1234f; + float rangeMax = 0.1234f; + float intScale; + float intOffset; + getScaleOffsetForFormat(rangeMin, rangeMax, true, format, intScale, intOffset); + channelDescriptors.add(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", "", rangeMin, rangeMax, + VolumeDataMapping.DIRECT, 1, + VolumeDataChannelDescriptor.Default, 0.f, intScale, intOffset); + + //OpenVDS::InMemoryOpenOptions options; + VDSFileOpenOptions options = new VDSFileOpenOptions("/mnt/dataDD/tmp/create.vds"); + OpenVDS.Error error; + + MetadataContainer metadataContainer; + metadataContainer.SetMetadataInt("categoryInt", "Int", 123); + metadataContainer.SetMetadataIntVector2("categoryInt", "IntVector2", OpenVDS.IntVector2 (45, 78)); + metadataContainer.SetMetadataIntVector3("categoryInt", "IntVector3", OpenVDS.IntVector3 (45, 78, 72)); + metadataContainer.SetMetadataIntVector4("categoryInt", "IntVector4", OpenVDS.IntVector4 (45, 78, 72, 84)); + metadataContainer.SetMetadataFloat("categoryFloat", "Float", 123.f); + metadataContainer.SetMetadataFloatVector2("categoryFloat", "FloatVector2", OpenVDS::FloatVector2 (45.5f, 78.75f)); + metadataContainer.SetMetadataFloatVector3("categoryFloat", "FloatVector3", + OpenVDS::FloatVector3 (45.5f, 78.75f, 72.75f)); + metadataContainer.SetMetadataFloatVector4("categoryFloat", "FloatVector4", + OpenVDS::FloatVector4 (45.5f, 78.75f, 72.75f, 84.1f)); + metadataContainer.SetMetadataDouble("categoryDouble", "Double", 123.); + metadataContainer.SetMetadataDoubleVector2("categoryDouble", "DoubleVector2", OpenVDS::DoubleVector2 + (45.5, 78.75)); + metadataContainer.SetMetadataDoubleVector3("categoryDouble", "DoubleVector3", + OpenVDS::DoubleVector3 (45.5, 78.75, 72.75)); + metadataContainer.SetMetadataDoubleVector4("categoryDouble", "DoubleVector4", + OpenVDS::DoubleVector4 (45.5, 78.75, 72.75, 84.1)); + metadataContainer.SetMetadataString("categoryString", "String", std::string ("Test string")); +//metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); + + VdsHandle vds = OpenVDS.create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, + error); + + VolumeDataLayout layout = vds.getLayout(); + //ASSERT_TRUE(layout); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor(layout, DimensionsND.DIMENSIONS_012, channel, 0, 100, VolumeDataAccessManager.AccessMode.CREATE) + + //ASSERT_TRUE(pageAccessor); + + int chunkCount = (int) pageAccessor.getChunkCount(); + + //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); + for (int i = 0; i < chunkCount; i++) { + VolumeDataPage page = pageAccessor.createPage(i); + VolumeIndexer3D outputIndexer(page, 0, 0, DimensionsND.DIMENSIONS_012, layout); + + //float valueRangeScale = outputIndexer.valueRangeMax - outputIndexer.valueRangeMin; + //QuantizingValueConverterWithNoValue converter(outputIndexer3D.valueRangeMin, outputIndexer3D.valueRangeMax, valueRangeScale, outputIndexer3D.valueRangeMin, noValue, noValue); + + int[] numSamples = new int[3]; + //OpenVDS::IntVector<3> localOutIndex; + + for (int j = 0; j < 3; j++) { + numSamples[j] = outputIndexer.getDataBlockNumSamples(j); + } + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + + void *buffer = page.getWritableBuffer(pitch); + auto output = static_cast < float *>(buffer); + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + int[] localOutIndex = new int[]{iDim0, iDim1, iDim2}; + + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localOutIndex); + + int pos[] = new int[]{ + voxelIndex[0], + voxelIndex[1], + voxelIndex[2] + }; + + float value = pos[0]; + + output[outputIndexer.localIndexToDataIndex(localOutIndex)] = value; + } + + //OpenVDS::CalculateNoise3D(buffer, format, &outputIndexer, frequency, 0.021f, 0.f, true, 345); + page.release(); + } + + pageAccessor.commit(); + pageAccessor.setMaxPages(0); + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + + OpenVDS.close(vds); + } + + static void getScaleOffsetForFormat(float min, float max, boolean novalue, VolumeDataChannelDescriptor.Format format, + float scale, float offset) { + switch (format) { + case VolumeDataChannelDescriptor.Format.FORMAT_U8: + scale = 1.f / (255.f - novalue) * (max - min); + offset = min; + break; + case VolumeDataChannelDescriptor.Format.FORMAT_U16: + scale = 1.f / (65535.f - novalue) * (max - min); + offset = min; + break; + case VolumeDataChannelDescriptor.Format.FORMAT_R32: + case VolumeDataChannelDescriptor.Format.FORMAT_U32: + case VolumeDataChannelDescriptor.Format.FORMAT_R64: + case VolumeDataChannelDescriptor.Format.FORMAT_U64: + case VolumeDataChannelDescriptor.Format.FORMAT_1BIT: + case VolumeDataChannelDescriptor.Format.FORMAT_ANY: + scale = 1.0f; + offset = 0.0f; + } + } +*/ } diff --git a/java/java/demo/WriteDataDemo.java b/java/java/demo/WriteDataDemo.java new file mode 100644 index 00000000..1259c711 --- /dev/null +++ b/java/java/demo/WriteDataDemo.java @@ -0,0 +1,178 @@ +import org.opengroup.openvds.*; + +import java.io.IOException; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +public class WriteDataDemo { + public static void main(String[] args) throws IOException { + roundtrip_2d(); + roundtrip_3d(); + } + + private static void roundtrip_2d() throws IOException { + final int nz = 113; + final int nx = 128; + + AzureOpenOptions options = new AzureOpenOptions(); + options.connectionString = System.getenv("CONNECTION_STRING"); + + if (options.connectionString == null) { + return; + } + + options.container = "test"; + options.blob = "rtrip_2d"; + + String[] names = new String[]{"chan1", "chan2"}; + VolumeDataChannelDescriptor.Format f = VolumeDataChannelDescriptor.Format.FORMAT_R32; + VdsHandle vds = new org.opengroup.openvds.AzureVdsGenerator(options, nz, nx, f, names); + + java.util.Random r = new java.util.Random(); + + double[] src1 = r.doubles(nx * nz).toArray(); + double[] src2 = r.doubles(nx * nz).toArray(); + + OpenVDS.writeArray(vds, src1, "chan1"); + OpenVDS.writeArray(vds, src2, "chan2"); + + vds.getAccessManager().flushUploadQueue(); + VdsHandle vds2; + + try { + vds2 = OpenVDS.open(options); + } catch (java.io.IOException e) { + fail(); + return; + } + + VolumeDataAccessManager access = vds2.getAccessManager(); + VolumeDataLayout layout = vds2.getLayout(); + NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nz, nx, 0, 0, 0, 0); + + int channel = layout.getChannelIndex("chan1"); + long size = access.getVolumeSubsetBufferSize(layout, box, f, 0, channel); + + java.nio.FloatBuffer outbuf = BufferUtils.createFloatBuffer((int) size / 4); + DimensionsND dims = DimensionsND.DIMENSIONS_01; + + long t = access.requestVolumeSubset(outbuf, layout, dims, 0, channel, box); + access.waitForCompletion(t); + float[] arr = new float[outbuf.remaining()]; + outbuf.get(arr); + assertEquals(arr[0], src1[0], 1e-6); + assertEquals(arr[1], src1[1], 1e-6); + assertEquals(arr[nx], src1[nx], 1e-6); + } + + + private static void roundtrip_3d() throws IOException { + final int nz = 113; + final int ny = 107; + final int nx = 108; + +// AzureOpenOptions options = new AzureOpenOptions(); +// options.connectionString = System.getenv("CONNECTION_STRING"); +// +// if (options.connectionString == null) { +// return; +// } +// +// options.container = "test"; +// options.blob = "rtrip_3d"; +// +// String[] names = new String[]{"chan1", "chan2"}; +// VolumeDataChannelDescriptor.Format f = VolumeDataChannelDescriptor.Format.FORMAT_R32; +// VdsHandle vds = new org.opengroup.openvds.AzureVdsGenerator(options, nz, ny, nx, f, names); + + VDSFileOpenOptions options = new VDSFileOpenOptions(); + options.filePath = "/mnt/dataDD/tmp/test.vds"; + + if (options.filePath == null) { + return; + } + + String[] names = new String[]{"chan1", "chan2"}; + VolumeDataChannelDescriptor.Format f = VolumeDataChannelDescriptor.Format.FORMAT_R32; + + VolumeDataLayoutDescriptor ld = new VolumeDataLayoutDescriptor( + VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_64, + 0, + 0, + 4, + VolumeDataLayoutDescriptor.LODLevels.LOD_LEVELS_NONE, + false, + false, + -1); + + VolumeDataAxisDescriptor[] vda = new VolumeDataAxisDescriptor[]{ + new VolumeDataAxisDescriptor(nz, "Sample", "ms", 0, nz * 4), + new VolumeDataAxisDescriptor(ny, "Xline", null, 0, ny), + new VolumeDataAxisDescriptor(nx, "Inline", null, 0, nx) + }; + + /** True data range */ + float valueRangeMax = Float.MAX_VALUE; + float valueRangeMin = -Float.MAX_VALUE; + + VolumeDataChannelDescriptor[] vdc = new VolumeDataChannelDescriptor[]{ + new VolumeDataChannelDescriptor( + VolumeDataChannelDescriptor.Format.FORMAT_R32, + VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", "", + valueRangeMin, valueRangeMax, VolumeDataMapping.DIRECT, + 1, false, true, true, false, false, 0f, 1f, 0f), + new VolumeDataChannelDescriptor( + VolumeDataChannelDescriptor.Format.FORMAT_U8, + VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Trace", "", + 0, 1, VolumeDataMapping.PER_TRACE, + 1, true, true, false, false, false, 0, 1f, 0f), + new VolumeDataChannelDescriptor( + VolumeDataChannelDescriptor.Format.FORMAT_U8, + VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "SEGYTraceHeader", "", + 0, 255, VolumeDataMapping.PER_TRACE, + 240, true, true, false, false, false, 0, 1f, 0f) + }; + + MetadataReadAccess md = new MetadataReadAccess(0); + VdsHandle vds = OpenVDS.create(options, ld, vda, vdc, md); + + java.util.Random r = new java.util.Random(); + + double[] src1 = r.doubles(nx * ny * nz).toArray(); + + float[] src2 = new float[src1.length]; + for (int i = 0; i < src2.length; i++) + src2[i] = i; + + OpenVDS.writeArray(vds, src1, "chan1"); + OpenVDS.writeArray(vds, src2, "chan2"); + + vds.getAccessManager().flushUploadQueue(); + VdsHandle vds2; + + vds2 = OpenVDS.open(options); + + VolumeDataAccessManager access = vds2.getAccessManager(); + VolumeDataLayout layout = vds2.getLayout(); + + NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nz, ny, nx, 0, 0, 0); + + int channel = layout.getChannelIndex("chan2"); + long size = access.getVolumeSubsetBufferSize(layout, box, f, 0, channel); + java.nio.FloatBuffer outbuf = BufferUtils.createFloatBuffer((int) size / 4); + DimensionsND dims = DimensionsND.DIMENSIONS_012; + + long t = access.requestVolumeSubset(outbuf, layout, dims, 0, channel, box); + access.waitForCompletion(t); + float[] arr = new float[outbuf.remaining()]; + outbuf.get(arr); +// assertEquals(arr[0], src2[0], 1e-6); +// assertEquals(arr[nx], src2[nx], 1e-6); +// assertEquals(arr[nx * ny], src2[nx * ny], 1e-6); +// assertEquals(arr[nx * ny * nz - 42], src2[nx * ny * nz - 42], 1e-6); + } +} diff --git a/java/java/src/org/opengroup/openvds/JniPointer.java b/java/java/src/org/opengroup/openvds/JniPointer.java index 3e162aa0..95d678c5 100644 --- a/java/java/src/org/opengroup/openvds/JniPointer.java +++ b/java/java/src/org/opengroup/openvds/JniPointer.java @@ -29,7 +29,7 @@ import java.util.logging.Logger; */ public abstract class JniPointer { - static final String JNI_LIB_NAME = "openvds-javacpp"; + static final String JNI_LIB_NAME = "openvds-javacppd"; private static final Logger LOGGER = Logger.getLogger(JniPointer.class.getName()); private static final String ERR_LIBRARY = "JNI library load failed"; diff --git a/java/java/src/org/opengroup/openvds/OpenVDS.java b/java/java/src/org/opengroup/openvds/OpenVDS.java index 3a48f73c..ca8a92f7 100644 --- a/java/java/src/org/opengroup/openvds/OpenVDS.java +++ b/java/java/src/org/opengroup/openvds/OpenVDS.java @@ -38,6 +38,9 @@ public class OpenVDS extends VdsHandle{ VolumeDataLayoutDescriptor ld, VolumeDataAxisDescriptor[] vda, VolumeDataChannelDescriptor[] vdc, MetadataReadAccess md) throws IOException; + private static native long cpCreateVDSFile(String pFilePath, + VolumeDataLayoutDescriptor ld, VolumeDataAxisDescriptor[] vda, + VolumeDataChannelDescriptor[] vdc, MetadataReadAccess md) throws IOException; private static native long cpCreateAws(String bucket, String key, String region, String endpointoverhide, String accessKeyId, String secretKey, String sessionToken, String expiration, VolumeDataLayoutDescriptor ld, VolumeDataAxisDescriptor[] vda, @@ -132,6 +135,15 @@ public class OpenVDS extends VdsHandle{ ld, vda, vdc, md), true); } + public static OpenVDS create(VDSFileOpenOptions o, VolumeDataLayoutDescriptor ld, + VolumeDataAxisDescriptor[] vda, VolumeDataChannelDescriptor[] vdc, + MetadataReadAccess md) throws IOException { + validateCreateArguments(o, ld, vda, vdc, md); + + return new OpenVDS(cpCreateVDSFile(o.filePath, + ld, vda, vdc, md), true); + } + public static OpenVDS create(AWSOpenOptions o, VolumeDataLayoutDescriptor ld, VolumeDataAxisDescriptor[] vda, VolumeDataChannelDescriptor[] vdc, MetadataReadAccess md) throws IOException { diff --git a/java/java/src/org/opengroup/openvds/VolumeDataAxisDescriptor.java b/java/java/src/org/opengroup/openvds/VolumeDataAxisDescriptor.java index 6c5c5d8e..6d160d4a 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataAxisDescriptor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataAxisDescriptor.java @@ -28,6 +28,14 @@ public class VolumeDataAxisDescriptor { private float coordinateMin; private float coordinateMax; + public VolumeDataAxisDescriptor(int numSamples, String name, String unit, float coordinateMin, float coordinateMax) { + this.numSamples = numSamples; + this.name = name; + this.unit = unit; + this.coordinateMin = coordinateMin; + this.coordinateMax = coordinateMax; + } + public int getNumSamples() { return numSamples; } diff --git a/java/java/src/org/opengroup/openvds/VolumeDataChannelDescriptor.java b/java/java/src/org/opengroup/openvds/VolumeDataChannelDescriptor.java index 1d77e8b5..3dab388e 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataChannelDescriptor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataChannelDescriptor.java @@ -126,6 +126,40 @@ public class VolumeDataChannelDescriptor { private float integerScale; private float integerOffset; + public VolumeDataChannelDescriptor( + Format format, + Components components, + String name, + String unit, + float valueRangeMin, float valueRangeMax, + VolumeDataMapping mapping, + int mappedValueCount, + boolean isDiscrete, + boolean isRenderable, + boolean isAllowLossyCompression, + boolean isUseZipForLosslessCompression, + boolean useNoValue, + float noValue, + float integerScale, + float integerOffset) { + this.format = format.code; + this.components = components.code; + this.name = name; + this.unit = unit; + this.valueRangeMin = valueRangeMin; + this.valueRangeMax = valueRangeMax; + this.mapping = mapping.code; + this.mappedValueCount = mappedValueCount; + this.isDiscrete = isDiscrete; + this.isRenderable = isRenderable; + this.isAllowLossyCompression = isAllowLossyCompression; + this.isUseZipForLosslessCompression = isUseZipForLosslessCompression; + this.useNoValue = useNoValue; + this.noValue = noValue; + this.integerScale = integerScale; + this.integerOffset = integerOffset; + } + public int getFormat() { return format; } diff --git a/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java b/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java index e43070c3..5e2eaaa3 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java @@ -81,7 +81,7 @@ public class VolumeDataLayoutDescriptor { IS_FORCE_FULL_RESOLUTION_DIMENSION = 6, FULL_RESOLUTION_DIMENSION = 7; - private int[] _values; + private int[] _values = new int[8]; public VolumeDataLayoutDescriptor(BrickSize brickSize, int negativeMargin, int positiveMargin, int brickSize2DMultiplier, LODLevels lodLevels, diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 8f083423..87230e82 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -14,3 +14,4 @@ endfunction() add_subdirectory(SEGYImport) add_subdirectory(SEGYExport) add_subdirectory(VDSInfo) +add_subdirectory(ScratchVDSFileCreate) diff --git a/tools/ScratchVDSFileCreate/CMakeLists.txt b/tools/ScratchVDSFileCreate/CMakeLists.txt new file mode 100644 index 00000000..9f1d3f96 --- /dev/null +++ b/tools/ScratchVDSFileCreate/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(VDSFileCreate + VDSFileCreate.cpp + ) + +target_link_libraries(VDSFileCreate PRIVATE Threads::Threads openvds segyutils jsoncpp_lib_static fmt::fmt) + +setCompilerFlagsForTools(VDSFileCreate) diff --git a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp new file mode 100644 index 00000000..5ea808d6 --- /dev/null +++ b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp @@ -0,0 +1,227 @@ +/**************************************************************************** +** Copyright 2019 The Open Group +** Copyright 2019 Bluware, Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +****************************************************************************/ + +#define _CRT_SECURE_NO_WARNINGS 1 + +#include +#include "IO/File.h" +#include "VDS/Hash.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "cxxopts.hpp" +#include +#include + +#include + +#if defined(WIN32) +#undef WIN32_LEAN_AND_MEAN // avoid warnings if defined on command line +#define WIN32_LEAN_AND_MEAN 1 +#define NOMINMAX 1 +#include +#include + +int64_t GetTotalSystemMemory() +{ + MEMORYSTATUSEX status; + status.dwLength = sizeof(status); + GlobalMemoryStatusEx(&status); + return int64_t(status.ullTotalPhys); +} + +#else + +#include + + +int64_t GetTotalSystemMemory() { + long pages = sysconf(_SC_PHYS_PAGES); + long page_size = sysconf(_SC_PAGE_SIZE); + return int64_t(pages) * int64_t(page_size); +} + +#endif + +static void +getScaleOffsetForFormat(float min, float max, bool novalue, OpenVDS::VolumeDataChannelDescriptor::Format format, + float &scale, float &offset) { + switch (format) { + case OpenVDS::VolumeDataChannelDescriptor::Format_U8: + scale = 1.f / (255.f - novalue) * (max - min); + offset = min; + break; + case OpenVDS::VolumeDataChannelDescriptor::Format_U16: + scale = 1.f / (65535.f - novalue) * (max - min); + offset = min; + break; + case OpenVDS::VolumeDataChannelDescriptor::Format_R32: + case OpenVDS::VolumeDataChannelDescriptor::Format_U32: + case OpenVDS::VolumeDataChannelDescriptor::Format_R64: + case OpenVDS::VolumeDataChannelDescriptor::Format_U64: + case OpenVDS::VolumeDataChannelDescriptor::Format_1Bit: + case OpenVDS::VolumeDataChannelDescriptor::Format_Any: + scale = 1.0f; + offset = 0.0f; + } +} + +int +main(int argc, char *argv[]) { + int32_t samplesX = 1000; + int32_t samplesY = 1000; + int32_t samplesZ = 1000; + OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; + + auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_64; + int negativeMargin = 4; + int positiveMargin = 4; + int brickSize2DMultiplier = 4; + auto lodLevels = OpenVDS::VolumeDataLayoutDescriptor::LODLevels_None; + auto layoutOptions = OpenVDS::VolumeDataLayoutDescriptor::Options_None; + OpenVDS::VolumeDataLayoutDescriptor layoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, layoutOptions); + + std::vector axisDescriptors; + axisDescriptors.emplace_back(samplesX, "Sample", "ms", 0.0f, + 4.f); + axisDescriptors.emplace_back(samplesY, "Crossline", "", + 1932.f, 2536.f); + axisDescriptors.emplace_back(samplesZ, "Inline", "", 9985.f, + 10369.f); + + std::vector channelDescriptors; + float rangeMin = -0.1234f; + float rangeMax = 0.1234f; + float intScale; + float intOffset; + getScaleOffsetForFormat(rangeMin, rangeMax, true, format, intScale, intOffset); + channelDescriptors.emplace_back(format, OpenVDS::VolumeDataChannelDescriptor::Components_1, + AMPLITUDE_ATTRIBUTE_NAME, "", rangeMin, rangeMax, + OpenVDS::VolumeDataMapping::Direct, 1, + OpenVDS::VolumeDataChannelDescriptor::Default, 0.f, intScale, intOffset); + + //OpenVDS::InMemoryOpenOptions options; + OpenVDS::VDSFileOpenOptions options("/mnt/dataDD/tmp/create.vds"); + OpenVDS::Error error; + + OpenVDS::MetadataContainer metadataContainer; + metadataContainer.SetMetadataInt("categoryInt", "Int", 123); + metadataContainer.SetMetadataIntVector2("categoryInt", "IntVector2", OpenVDS::IntVector2(45, 78)); + metadataContainer.SetMetadataIntVector3("categoryInt", "IntVector3", OpenVDS::IntVector3(45, 78, 72)); + metadataContainer.SetMetadataIntVector4("categoryInt", "IntVector4", OpenVDS::IntVector4(45, 78, 72, 84)); + metadataContainer.SetMetadataFloat("categoryFloat", "Float", 123.f); + metadataContainer.SetMetadataFloatVector2("categoryFloat", "FloatVector2", OpenVDS::FloatVector2(45.5f, 78.75f)); + metadataContainer.SetMetadataFloatVector3("categoryFloat", "FloatVector3", + OpenVDS::FloatVector3(45.5f, 78.75f, 72.75f)); + metadataContainer.SetMetadataFloatVector4("categoryFloat", "FloatVector4", + OpenVDS::FloatVector4(45.5f, 78.75f, 72.75f, 84.1f)); + metadataContainer.SetMetadataDouble("categoryDouble", "Double", 123.); + metadataContainer.SetMetadataDoubleVector2("categoryDouble", "DoubleVector2", OpenVDS::DoubleVector2(45.5, 78.75)); + metadataContainer.SetMetadataDoubleVector3("categoryDouble", "DoubleVector3", + OpenVDS::DoubleVector3(45.5, 78.75, 72.75)); + metadataContainer.SetMetadataDoubleVector4("categoryDouble", "DoubleVector4", + OpenVDS::DoubleVector4(45.5, 78.75, 72.75, 84.1)); + metadataContainer.SetMetadataString("categoryString", "String", std::string("Test string")); +//metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); + + auto vds = OpenVDS::Create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, + error); + + OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(vds); + //ASSERT_TRUE(layout); + OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(vds); + //ASSERT_TRUE(accessManager); + + int32_t channel = 0; + OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); + //ASSERT_TRUE(pageAccessor); + + int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); + + //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); + for (int i = 0; i < chunkCount; i++) + { + OpenVDS::VolumeDataPage *page = pageAccessor->CreatePage(i); + OpenVDS::VolumeIndexer3D outputIndexer(page, 0, 0, OpenVDS::Dimensions_012, layout); + + //float valueRangeScale = outputIndexer.valueRangeMax - outputIndexer.valueRangeMin; + //QuantizingValueConverterWithNoValue converter(outputIndexer3D.valueRangeMin, outputIndexer3D.valueRangeMax, valueRangeScale, outputIndexer3D.valueRangeMin, noValue, noValue); + + OpenVDS::IntVector<3> numSamples; + //OpenVDS::IntVector<3> localOutIndex; + + for (int j=0; j<3; j++) + { + numSamples[j] = outputIndexer.GetDataBlockNumSamples(j); + } + + int pitch[OpenVDS::Dimensionality_Max]; + void *buffer = page->GetWritableBuffer(pitch); + + auto output = static_cast(buffer); + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) + { + OpenVDS::IntVector<3> + localOutIndex(iDim0, iDim1, iDim2); + + OpenVDS::IntVector<3> + voxelIndex = outputIndexer.LocalIndexToVoxelIndex(localOutIndex); + + int pos[3] = { voxelIndex[0], + voxelIndex[1], + voxelIndex[2]}; + + float value = pos[0]; + + output[outputIndexer.LocalIndexToDataIndex(localOutIndex)] = value; + } + + //OpenVDS::CalculateNoise3D(buffer, format, &outputIndexer, frequency, 0.021f, 0.f, true, 345); + page->Release(); + } + + pageAccessor->Commit(); + pageAccessor->SetMaxPages(0); + accessManager->FlushUploadQueue(); + accessManager->DestroyVolumeDataPageAccessor(pageAccessor); + + OpenVDS::Close(vds); + + return EXIT_SUCCESS; +} diff --git a/tools/ScratchVDSFileCreate/cxxopts.hpp b/tools/ScratchVDSFileCreate/cxxopts.hpp new file mode 100644 index 00000000..63d6336d --- /dev/null +++ b/tools/ScratchVDSFileCreate/cxxopts.hpp @@ -0,0 +1,2087 @@ +/* + +Copyright (c) 2014, 2015, 2016, 2017 Jarryd Beck + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +#ifndef CXXOPTS_HPP_INCLUDED +#define CXXOPTS_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cpp_lib_optional +#include +#define CXXOPTS_HAS_OPTIONAL +#endif + +#define CXXOPTS__VERSION_MAJOR 2 +#define CXXOPTS__VERSION_MINOR 2 +#define CXXOPTS__VERSION_PATCH 0 + +namespace cxxopts +{ + static constexpr struct { + uint8_t major, minor, patch; + } version = { + CXXOPTS__VERSION_MAJOR, + CXXOPTS__VERSION_MINOR, + CXXOPTS__VERSION_PATCH + }; +} + +//when we ask cxxopts to use Unicode, help strings are processed using ICU, +//which results in the correct lengths being computed for strings when they +//are formatted for the help output +//it is necessary to make sure that can be found by the +//compiler, and that icu-uc is linked in to the binary. + +#ifdef CXXOPTS_USE_UNICODE +#include + +namespace cxxopts +{ + typedef icu::UnicodeString String; + + inline + String + toLocalString(std::string s) + { + return icu::UnicodeString::fromUTF8(std::move(s)); + } + + class UnicodeStringIterator : public + std::iterator + { + public: + + UnicodeStringIterator(const icu::UnicodeString* string, int32_t pos) + : s(string) + , i(pos) + { + } + + value_type + operator*() const + { + return s->char32At(i); + } + + bool + operator==(const UnicodeStringIterator& rhs) const + { + return s == rhs.s && i == rhs.i; + } + + bool + operator!=(const UnicodeStringIterator& rhs) const + { + return !(*this == rhs); + } + + UnicodeStringIterator& + operator++() + { + ++i; + return *this; + } + + UnicodeStringIterator + operator+(int32_t v) + { + return UnicodeStringIterator(s, i + v); + } + + private: + const icu::UnicodeString* s; + int32_t i; + }; + + inline + String& + stringAppend(String&s, String a) + { + return s.append(std::move(a)); + } + + inline + String& + stringAppend(String& s, int n, UChar32 c) + { + for (int i = 0; i != n; ++i) + { + s.append(c); + } + + return s; + } + + template + String& + stringAppend(String& s, Iterator begin, Iterator end) + { + while (begin != end) + { + s.append(*begin); + ++begin; + } + + return s; + } + + inline + size_t + stringLength(const String& s) + { + return s.length(); + } + + inline + std::string + toUTF8String(const String& s) + { + std::string result; + s.toUTF8String(result); + + return result; + } + + inline + bool + empty(const String& s) + { + return s.isEmpty(); + } +} + +namespace std +{ + inline + cxxopts::UnicodeStringIterator + begin(const icu::UnicodeString& s) + { + return cxxopts::UnicodeStringIterator(&s, 0); + } + + inline + cxxopts::UnicodeStringIterator + end(const icu::UnicodeString& s) + { + return cxxopts::UnicodeStringIterator(&s, s.length()); + } +} + +//ifdef CXXOPTS_USE_UNICODE +#else + +namespace cxxopts +{ + typedef std::string String; + + template + T + toLocalString(T&& t) + { + return std::forward(t); + } + + inline + size_t + stringLength(const String& s) + { + return s.length(); + } + + inline + String& + stringAppend(String&s, String a) + { + return s.append(std::move(a)); + } + + inline + String& + stringAppend(String& s, size_t n, char c) + { + return s.append(n, c); + } + + template + String& + stringAppend(String& s, Iterator begin, Iterator end) + { + return s.append(begin, end); + } + + template + std::string + toUTF8String(T&& t) + { + return std::forward(t); + } + + inline + bool + empty(const std::string& s) + { + return s.empty(); + } +} + +//ifdef CXXOPTS_USE_UNICODE +#endif + +namespace cxxopts +{ + namespace + { +#ifdef _WIN32 + const std::string LQUOTE("\'"); + const std::string RQUOTE("\'"); +#else + const std::string LQUOTE("‘"); + const std::string RQUOTE("’"); +#endif + } + + class Value : public std::enable_shared_from_this + { + public: + + virtual ~Value() = default; + + virtual + std::shared_ptr + clone() const = 0; + + virtual void + parse(const std::string& text) const = 0; + + virtual void + parse() const = 0; + + virtual bool + has_default() const = 0; + + virtual bool + is_container() const = 0; + + virtual bool + has_implicit() const = 0; + + virtual std::string + get_default_value() const = 0; + + virtual std::string + get_implicit_value() const = 0; + + virtual std::shared_ptr + default_value(const std::string& value) = 0; + + virtual std::shared_ptr + implicit_value(const std::string& value) = 0; + + virtual bool + is_boolean() const = 0; + }; + + class OptionException : public std::exception + { + public: + OptionException(const std::string& message) + : m_message(message) + { + } + + virtual const char* + what() const noexcept + { + return m_message.c_str(); + } + + private: + std::string m_message; + }; + + class OptionSpecException : public OptionException + { + public: + + OptionSpecException(const std::string& message) + : OptionException(message) + { + } + }; + + class OptionParseException : public OptionException + { + public: + OptionParseException(const std::string& message) + : OptionException(message) + { + } + }; + + class option_exists_error : public OptionSpecException + { + public: + option_exists_error(const std::string& option) + : OptionSpecException("Option " + LQUOTE + option + RQUOTE + " already exists") + { + } + }; + + class invalid_option_format_error : public OptionSpecException + { + public: + invalid_option_format_error(const std::string& format) + : OptionSpecException("Invalid option format " + LQUOTE + format + RQUOTE) + { + } + }; + + class option_syntax_exception : public OptionParseException { + public: + option_syntax_exception(const std::string& text) + : OptionParseException("Argument " + LQUOTE + text + RQUOTE + + " starts with a - but has incorrect syntax") + { + } + }; + + class option_not_exists_exception : public OptionParseException + { + public: + option_not_exists_exception(const std::string& option) + : OptionParseException("Option " + LQUOTE + option + RQUOTE + " does not exist") + { + } + }; + + class missing_argument_exception : public OptionParseException + { + public: + missing_argument_exception(const std::string& option) + : OptionParseException( + "Option " + LQUOTE + option + RQUOTE + " is missing an argument" + ) + { + } + }; + + class option_requires_argument_exception : public OptionParseException + { + public: + option_requires_argument_exception(const std::string& option) + : OptionParseException( + "Option " + LQUOTE + option + RQUOTE + " requires an argument" + ) + { + } + }; + + class option_not_has_argument_exception : public OptionParseException + { + public: + option_not_has_argument_exception + ( + const std::string& option, + const std::string& arg + ) + : OptionParseException( + "Option " + LQUOTE + option + RQUOTE + + " does not take an argument, but argument " + + LQUOTE + arg + RQUOTE + " given" + ) + { + } + }; + + class option_not_present_exception : public OptionParseException + { + public: + option_not_present_exception(const std::string& option) + : OptionParseException("Option " + LQUOTE + option + RQUOTE + " not present") + { + } + }; + + class argument_incorrect_type : public OptionParseException + { + public: + argument_incorrect_type + ( + const std::string& arg + ) + : OptionParseException( + "Argument " + LQUOTE + arg + RQUOTE + " failed to parse" + ) + { + } + }; + + class option_required_exception : public OptionParseException + { + public: + option_required_exception(const std::string& option) + : OptionParseException( + "Option " + LQUOTE + option + RQUOTE + " is required but not present" + ) + { + } + }; + + namespace values + { + namespace + { + std::basic_regex integer_pattern + ("(-)?(0x)?([0-9a-zA-Z]+)|((0x)?0)"); + std::basic_regex truthy_pattern + ("(t|T)(rue)?|1"); + std::basic_regex falsy_pattern + ("(f|F)(alse)?|0"); + } + + namespace detail + { + template + struct SignedCheck; + + template + struct SignedCheck + { + template + void + operator()(bool negative, U u, const std::string& text) + { + if (negative) + { + if (u > static_cast(-(std::numeric_limits::min)())) + { + throw argument_incorrect_type(text); + } + } + else + { + if (u > static_cast((std::numeric_limits::max)())) + { + throw argument_incorrect_type(text); + } + } + } + }; + + template + struct SignedCheck + { + template + void + operator()(bool, U, const std::string&) {} + }; + + template + void + check_signed_range(bool negative, U value, const std::string& text) + { + SignedCheck::is_signed>()(negative, value, text); + } + } + + template + R + checked_negate(T&& t, const std::string&, std::true_type) + { + // if we got to here, then `t` is a positive number that fits into + // `R`. So to avoid MSVC C4146, we first cast it to `R`. + // See https://github.com/jarro2783/cxxopts/issues/62 for more details. + return -static_cast(t); + } + + template + T + checked_negate(T&&, const std::string& text, std::false_type) + { + throw argument_incorrect_type(text); + } + + template + void + integer_parser(const std::string& text, T& value) + { + std::smatch match; + std::regex_match(text, match, integer_pattern); + + if (match.length() == 0) + { + throw argument_incorrect_type(text); + } + + if (match.length(4) > 0) + { + value = 0; + return; + } + + using US = typename std::make_unsigned::type; + + constexpr auto umax = (std::numeric_limits::max)(); + constexpr bool is_signed = std::numeric_limits::is_signed; + const bool negative = match.length(1) > 0; + const uint8_t base = match.length(2) > 0 ? 16 : 10; + + auto value_match = match[3]; + + US result = 0; + + for (auto iter = value_match.first; iter != value_match.second; ++iter) + { + US digit = 0; + + if (*iter >= '0' && *iter <= '9') + { + digit = static_cast(*iter - '0'); + } + else if (base == 16 && *iter >= 'a' && *iter <= 'f') + { + digit = static_cast(*iter - 'a' + 10); + } + else if (base == 16 && *iter >= 'A' && *iter <= 'F') + { + digit = static_cast(*iter - 'A' + 10); + } + else + { + throw argument_incorrect_type(text); + } + + if (umax - digit < result * base) + { + throw argument_incorrect_type(text); + } + + result = result * base + digit; + } + + detail::check_signed_range(negative, result, text); + + if (negative) + { + value = checked_negate(result, + text, + std::integral_constant()); + } + else + { + value = static_cast(result); + } + } + + template + void stringstream_parser(const std::string& text, T& value) + { + std::stringstream in(text); + in >> value; + if (!in) { + throw argument_incorrect_type(text); + } + } + + inline + void + parse_value(const std::string& text, uint8_t& value) + { + integer_parser(text, value); + } + + inline + void + parse_value(const std::string& text, int8_t& value) + { + integer_parser(text, value); + } + + inline + void + parse_value(const std::string& text, uint16_t& value) + { + integer_parser(text, value); + } + + inline + void + parse_value(const std::string& text, int16_t& value) + { + integer_parser(text, value); + } + + inline + void + parse_value(const std::string& text, uint32_t& value) + { + integer_parser(text, value); + } + + inline + void + parse_value(const std::string& text, int32_t& value) + { + integer_parser(text, value); + } + + inline + void + parse_value(const std::string& text, uint64_t& value) + { + integer_parser(text, value); + } + + inline + void + parse_value(const std::string& text, int64_t& value) + { + integer_parser(text, value); + } + + inline + void + parse_value(const std::string& text, bool& value) + { + std::smatch result; + std::regex_match(text, result, truthy_pattern); + + if (!result.empty()) + { + value = true; + return; + } + + std::regex_match(text, result, falsy_pattern); + if (!result.empty()) + { + value = false; + return; + } + + throw argument_incorrect_type(text); + } + + inline + void + parse_value(const std::string& text, std::string& value) + { + value = text; + } + + // The fallback parser. It uses the stringstream parser to parse all types + // that have not been overloaded explicitly. It has to be placed in the + // source code before all other more specialized templates. + template + void + parse_value(const std::string& text, T& value) { + stringstream_parser(text, value); + } + + template + void + parse_value(const std::string& text, std::vector& value) + { + T v; + parse_value(text, v); + value.push_back(v); + } + +#ifdef CXXOPTS_HAS_OPTIONAL + template + void + parse_value(const std::string& text, std::optional& value) + { + T result; + parse_value(text, result); + value = std::move(result); + } +#endif + + template + struct type_is_container + { + static constexpr bool value = false; + }; + + template + struct type_is_container> + { + static constexpr bool value = true; + }; + + template + class abstract_value : public Value + { + using Self = abstract_value; + + public: + abstract_value() + : m_result(std::make_shared()) + , m_store(m_result.get()) + { + } + + abstract_value(T* t) + : m_store(t) + { + } + + virtual ~abstract_value() = default; + + abstract_value(const abstract_value& rhs) + { + if (rhs.m_result) + { + m_result = std::make_shared(); + m_store = m_result.get(); + } + else + { + m_store = rhs.m_store; + } + + m_default = rhs.m_default; + m_implicit = rhs.m_implicit; + m_default_value = rhs.m_default_value; + m_implicit_value = rhs.m_implicit_value; + } + + void + parse(const std::string& text) const + { + parse_value(text, *m_store); + } + + bool + is_container() const + { + return type_is_container::value; + } + + void + parse() const + { + parse_value(m_default_value, *m_store); + } + + bool + has_default() const + { + return m_default; + } + + bool + has_implicit() const + { + return m_implicit; + } + + std::shared_ptr + default_value(const std::string& value) + { + m_default = true; + m_default_value = value; + return shared_from_this(); + } + + std::shared_ptr + implicit_value(const std::string& value) + { + m_implicit = true; + m_implicit_value = value; + return shared_from_this(); + } + + std::string + get_default_value() const + { + return m_default_value; + } + + std::string + get_implicit_value() const + { + return m_implicit_value; + } + + bool + is_boolean() const + { + return std::is_same::value; + } + + const T& + get() const + { + if (m_store == nullptr) + { + return *m_result; + } + else + { + return *m_store; + } + } + + protected: + std::shared_ptr m_result; + T* m_store; + + bool m_default = false; + bool m_implicit = false; + + std::string m_default_value; + std::string m_implicit_value; + }; + + template + class standard_value : public abstract_value + { + public: + using abstract_value::abstract_value; + + std::shared_ptr + clone() const + { + return std::make_shared>(*this); + } + }; + + template <> + class standard_value : public abstract_value + { + public: + ~standard_value() = default; + + standard_value() + { + set_default_and_implicit(); + } + + standard_value(bool* b) + : abstract_value(b) + { + set_default_and_implicit(); + } + + std::shared_ptr + clone() const + { + return std::make_shared>(*this); + } + + private: + + void + set_default_and_implicit() + { + m_default = true; + m_default_value = "false"; + m_implicit = true; + m_implicit_value = "true"; + } + }; + } + + template + std::shared_ptr + value() + { + return std::make_shared>(); + } + + template + std::shared_ptr + value(T& t) + { + return std::make_shared>(&t); + } + + class OptionAdder; + + class OptionDetails + { + public: + OptionDetails + ( + const std::string& short_, + const std::string& long_, + const String& desc, + std::shared_ptr val + ) + : m_short(short_) + , m_long(long_) + , m_desc(desc) + , m_value(val) + , m_count(0) + { + } + + OptionDetails(const OptionDetails& rhs) + : m_desc(rhs.m_desc) + , m_count(rhs.m_count) + { + m_value = rhs.m_value->clone(); + } + + OptionDetails(OptionDetails&& rhs) = default; + + const String& + description() const + { + return m_desc; + } + + const Value& value() const { + return *m_value; + } + + std::shared_ptr + make_storage() const + { + return m_value->clone(); + } + + const std::string& + short_name() const + { + return m_short; + } + + const std::string& + long_name() const + { + return m_long; + } + + private: + std::string m_short; + std::string m_long; + String m_desc; + std::shared_ptr m_value; + int m_count; + }; + + struct HelpOptionDetails + { + std::string s; + std::string l; + String desc; + bool has_default; + std::string default_value; + bool has_implicit; + std::string implicit_value; + std::string arg_help; + bool is_container; + bool is_boolean; + }; + + struct HelpGroupDetails + { + std::string name; + std::string description; + std::vector options; + }; + + class OptionValue + { + public: + void + parse + ( + std::shared_ptr details, + const std::string& text + ) + { + ensure_value(details); + ++m_count; + m_value->parse(text); + } + + void + parse_default(std::shared_ptr details) + { + ensure_value(details); + m_value->parse(); + } + + size_t + count() const + { + return m_count; + } + + template + const T& + as() const + { + if (m_value == nullptr) { + throw std::domain_error("No value"); + } + +#ifdef CXXOPTS_NO_RTTI + return static_cast&>(*m_value).get(); +#else + return dynamic_cast&>(*m_value).get(); +#endif + } + + private: + void + ensure_value(std::shared_ptr details) + { + if (m_value == nullptr) + { + m_value = details->make_storage(); + } + } + + std::shared_ptr m_value; + size_t m_count = 0; + }; + + class KeyValue + { + public: + KeyValue(std::string key_, std::string value_) + : m_key(std::move(key_)) + , m_value(std::move(value_)) + { + } + + const + std::string& + key() const + { + return m_key; + } + + const + std::string& + value() const + { + return m_value; + } + + template + T + as() const + { + T result; + values::parse_value(m_value, result); + return result; + } + + private: + std::string m_key; + std::string m_value; + }; + + class ParseResult + { + public: + + ParseResult( + const std::shared_ptr< + std::unordered_map> + >, + std::vector, + bool allow_unrecognised, + int&, char**&); + + size_t + count(const std::string& o) const + { + auto iter = m_options->find(o); + if (iter == m_options->end()) + { + return 0; + } + + auto riter = m_results.find(iter->second); + + return riter->second.count(); + } + + const OptionValue& + operator[](const std::string& option) const + { + auto iter = m_options->find(option); + + if (iter == m_options->end()) + { + throw option_not_present_exception(option); + } + + auto riter = m_results.find(iter->second); + + return riter->second; + } + + const std::vector& + arguments() const + { + return m_sequential; + } + + private: + + void + parse(int& argc, char**& argv); + + void + add_to_option(const std::string& option, const std::string& arg); + + bool + consume_positional(std::string a); + + void + parse_option + ( + std::shared_ptr value, + const std::string& name, + const std::string& arg = "" + ); + + void + parse_default(std::shared_ptr details); + + void + checked_parse_arg + ( + int argc, + char* argv[], + int& current, + std::shared_ptr value, + const std::string& name + ); + + const std::shared_ptr< + std::unordered_map> + > m_options; + std::vector m_positional; + std::vector::iterator m_next_positional; + std::unordered_set m_positional_set; + std::unordered_map, OptionValue> m_results; + + bool m_allow_unrecognised; + + std::vector m_sequential; + }; + + class Options + { + typedef std::unordered_map> + OptionMap; + public: + + Options(std::string program, std::string help_string = "") + : m_program(std::move(program)) + , m_help_string(toLocalString(std::move(help_string))) + , m_custom_help("[OPTION...]") + , m_positional_help("positional parameters") + , m_show_positional(false) + , m_allow_unrecognised(false) + , m_options(std::make_shared()) + , m_next_positional(m_positional.end()) + { + } + + Options& + positional_help(std::string help_text) + { + m_positional_help = std::move(help_text); + return *this; + } + + Options& + custom_help(std::string help_text) + { + m_custom_help = std::move(help_text); + return *this; + } + + Options& + show_positional_help() + { + m_show_positional = true; + return *this; + } + + Options& + allow_unrecognised_options() + { + m_allow_unrecognised = true; + return *this; + } + + ParseResult + parse(int& argc, char**& argv); + + OptionAdder + add_options(std::string group = ""); + + void + add_option + ( + const std::string& group, + const std::string& s, + const std::string& l, + std::string desc, + std::shared_ptr value, + std::string arg_help + ); + + //parse positional arguments into the given option + void + parse_positional(std::string option); + + void + parse_positional(std::vector options); + + void + parse_positional(std::initializer_list options); + + template + void + parse_positional(Iterator begin, Iterator end) { + parse_positional(std::vector{begin, end}); + } + + std::string + help(const std::vector& groups = {}) const; + + const std::vector + groups() const; + + const HelpGroupDetails& + group_help(const std::string& group) const; + + private: + + void + add_one_option + ( + const std::string& option, + std::shared_ptr details + ); + + String + help_one_group(const std::string& group) const; + + void + generate_group_help + ( + String& result, + const std::vector& groups + ) const; + + void + generate_all_groups_help(String& result) const; + + std::string m_program; + String m_help_string; + std::string m_custom_help; + std::string m_positional_help; + bool m_show_positional; + bool m_allow_unrecognised; + + std::shared_ptr m_options; + std::vector m_positional; + std::vector::iterator m_next_positional; + std::unordered_set m_positional_set; + + //mapping from groups to help options + std::map m_help; + }; + + class OptionAdder + { + public: + + OptionAdder(Options& options, std::string group) + : m_options(options), m_group(std::move(group)) + { + } + + OptionAdder& + operator() + ( + const std::string& opts, + const std::string& desc, + std::shared_ptr value + = ::cxxopts::value(), + std::string arg_help = "" + ); + + private: + Options& m_options; + std::string m_group; + }; + + namespace + { + constexpr int OPTION_LONGEST = 30; + constexpr int OPTION_DESC_GAP = 2; + + std::basic_regex option_matcher + ("--([[:alnum:]][-_[:alnum:]]+)(=(.*))?|-([[:alnum:]]+)"); + + std::basic_regex option_specifier + ("(([[:alnum:]]),)?[ ]*([[:alnum:]][-_[:alnum:]]*)?"); + + String + format_option + ( + const HelpOptionDetails& o + ) + { + auto& s = o.s; + auto& l = o.l; + + String result = " "; + + if (s.size() > 0) + { + result += "-" + toLocalString(s) + ","; + } + else + { + result += " "; + } + + if (l.size() > 0) + { + result += " --" + toLocalString(l); + } + + auto arg = o.arg_help.size() > 0 ? toLocalString(o.arg_help) : "arg"; + + if (!o.is_boolean) + { + if (o.has_implicit) + { + result += " [=" + arg + "(=" + toLocalString(o.implicit_value) + ")]"; + } + else + { + result += " " + arg; + } + } + + return result; + } + + String + format_description + ( + const HelpOptionDetails& o, + size_t start, + size_t width + ) + { + auto desc = o.desc; + + if (o.has_default && (!o.is_boolean || o.default_value != "false")) + { + desc += toLocalString(" (default: " + o.default_value + ")"); + } + + String result; + + auto current = std::begin(desc); + auto startLine = current; + auto lastSpace = current; + + auto size = size_t{}; + + while (current != std::end(desc)) + { + if (*current == ' ') + { + lastSpace = current; + } + + if (*current == '\n') + { + startLine = current + 1; + lastSpace = startLine; + } + else if (size > width) + { + if (lastSpace == startLine) + { + stringAppend(result, startLine, current + 1); + stringAppend(result, "\n"); + stringAppend(result, start, ' '); + startLine = current + 1; + lastSpace = startLine; + } + else + { + stringAppend(result, startLine, lastSpace); + stringAppend(result, "\n"); + stringAppend(result, start, ' '); + startLine = lastSpace + 1; + } + size = 0; + } + else + { + ++size; + } + + ++current; + } + + //append whatever is left + stringAppend(result, startLine, current); + + return result; + } + } + +inline +ParseResult::ParseResult +( + const std::shared_ptr< + std::unordered_map> + > options, + std::vector positional, + bool allow_unrecognised, + int& argc, char**& argv +) +: m_options(options) +, m_positional(std::move(positional)) +, m_next_positional(m_positional.begin()) +, m_allow_unrecognised(allow_unrecognised) +{ + parse(argc, argv); +} + +inline +OptionAdder +Options::add_options(std::string group) +{ + return OptionAdder(*this, std::move(group)); +} + +inline +OptionAdder& +OptionAdder::operator() +( + const std::string& opts, + const std::string& desc, + std::shared_ptr value, + std::string arg_help +) +{ + std::match_results result; + std::regex_match(opts.c_str(), result, option_specifier); + + if (result.empty()) + { + throw invalid_option_format_error(opts); + } + + const auto& short_match = result[2]; + const auto& long_match = result[3]; + + if (!short_match.length() && !long_match.length()) + { + throw invalid_option_format_error(opts); + } else if (long_match.length() == 1 && short_match.length()) + { + throw invalid_option_format_error(opts); + } + + auto option_names = [] + ( + const std::sub_match& short_, + const std::sub_match& long_ + ) + { + if (long_.length() == 1) + { + return std::make_tuple(long_.str(), short_.str()); + } + else + { + return std::make_tuple(short_.str(), long_.str()); + } + }(short_match, long_match); + + m_options.add_option + ( + m_group, + std::get<0>(option_names), + std::get<1>(option_names), + desc, + value, + std::move(arg_help) + ); + + return *this; +} + +inline +void +ParseResult::parse_default(std::shared_ptr details) +{ + m_results[details].parse_default(details); +} + +inline +void +ParseResult::parse_option +( + std::shared_ptr value, + const std::string& /*name*/, + const std::string& arg +) +{ + auto& result = m_results[value]; + result.parse(value, arg); + + m_sequential.emplace_back(value->long_name(), arg); +} + +inline +void +ParseResult::checked_parse_arg +( + int argc, + char* argv[], + int& current, + std::shared_ptr value, + const std::string& name +) +{ + if (current + 1 >= argc) + { + if (value->value().has_implicit()) + { + parse_option(value, name, value->value().get_implicit_value()); + } + else + { + throw missing_argument_exception(name); + } + } + else + { + if (value->value().has_implicit()) + { + parse_option(value, name, value->value().get_implicit_value()); + } + else + { + parse_option(value, name, argv[current + 1]); + ++current; + } + } +} + +inline +void +ParseResult::add_to_option(const std::string& option, const std::string& arg) +{ + auto iter = m_options->find(option); + + if (iter == m_options->end()) + { + throw option_not_exists_exception(option); + } + + parse_option(iter->second, option, arg); +} + +inline +bool +ParseResult::consume_positional(std::string a) +{ + while (m_next_positional != m_positional.end()) + { + auto iter = m_options->find(*m_next_positional); + if (iter != m_options->end()) + { + auto& result = m_results[iter->second]; + if (!iter->second->value().is_container()) + { + if (result.count() == 0) + { + add_to_option(*m_next_positional, a); + ++m_next_positional; + return true; + } + else + { + ++m_next_positional; + continue; + } + } + else + { + add_to_option(*m_next_positional, a); + return true; + } + } + else + { + throw option_not_exists_exception(*m_next_positional); + } + } + + return false; +} + +inline +void +Options::parse_positional(std::string option) +{ + parse_positional(std::vector{std::move(option)}); +} + +inline +void +Options::parse_positional(std::vector options) +{ + m_positional = std::move(options); + m_next_positional = m_positional.begin(); + + m_positional_set.insert(m_positional.begin(), m_positional.end()); +} + +inline +void +Options::parse_positional(std::initializer_list options) +{ + parse_positional(std::vector(std::move(options))); +} + +inline +ParseResult +Options::parse(int& argc, char**& argv) +{ + ParseResult result(m_options, m_positional, m_allow_unrecognised, argc, argv); + return result; +} + +inline +void +ParseResult::parse(int& argc, char**& argv) +{ + int current = 1; + + int nextKeep = 1; + + bool consume_remaining = false; + + while (current != argc) + { + if (strcmp(argv[current], "--") == 0) + { + consume_remaining = true; + ++current; + break; + } + + std::match_results result; + std::regex_match(argv[current], result, option_matcher); + + if (result.empty()) + { + //not a flag + + // but if it starts with a `-`, then it's an error + if (argv[current][0] == '-' && argv[current][1] != '\0') { + if (!m_allow_unrecognised) { + throw option_syntax_exception(argv[current]); + } + } + + //if true is returned here then it was consumed, otherwise it is + //ignored + if (consume_positional(argv[current])) + { + } + else + { + argv[nextKeep] = argv[current]; + ++nextKeep; + } + //if we return from here then it was parsed successfully, so continue + } + else + { + //short or long option? + if (result[4].length() != 0) + { + const std::string& s = result[4]; + + for (std::size_t i = 0; i != s.size(); ++i) + { + std::string name(1, s[i]); + auto iter = m_options->find(name); + + if (iter == m_options->end()) + { + if (m_allow_unrecognised) + { + continue; + } + else + { + //error + throw option_not_exists_exception(name); + } + } + + auto value = iter->second; + + if (i + 1 == s.size()) + { + //it must be the last argument + checked_parse_arg(argc, argv, current, value, name); + } + else if (value->value().has_implicit()) + { + parse_option(value, name, value->value().get_implicit_value()); + } + else + { + //error + throw option_requires_argument_exception(name); + } + } + } + else if (result[1].length() != 0) + { + const std::string& name = result[1]; + + auto iter = m_options->find(name); + + if (iter == m_options->end()) + { + if (m_allow_unrecognised) + { + // keep unrecognised options in argument list, skip to next argument + argv[nextKeep] = argv[current]; + ++nextKeep; + ++current; + continue; + } + else + { + //error + throw option_not_exists_exception(name); + } + } + + auto opt = iter->second; + + //equals provided for long option? + if (result[2].length() != 0) + { + //parse the option given + + parse_option(opt, name, result[3]); + } + else + { + //parse the next argument + checked_parse_arg(argc, argv, current, opt, name); + } + } + + } + + ++current; + } + + for (auto& opt : *m_options) + { + auto& detail = opt.second; + auto& value = detail->value(); + + auto& store = m_results[detail]; + + if(!store.count() && value.has_default()){ + parse_default(detail); + } + } + + if (consume_remaining) + { + while (current < argc) + { + if (!consume_positional(argv[current])) { + break; + } + ++current; + } + + //adjust argv for any that couldn't be swallowed + while (current != argc) { + argv[nextKeep] = argv[current]; + ++nextKeep; + ++current; + } + } + + argc = nextKeep; + +} + +inline +void +Options::add_option +( + const std::string& group, + const std::string& s, + const std::string& l, + std::string desc, + std::shared_ptr value, + std::string arg_help +) +{ + auto stringDesc = toLocalString(std::move(desc)); + auto option = std::make_shared(s, l, stringDesc, value); + + if (s.size() > 0) + { + add_one_option(s, option); + } + + if (l.size() > 0) + { + add_one_option(l, option); + } + + //add the help details + auto& options = m_help[group]; + + options.options.emplace_back(HelpOptionDetails{s, l, stringDesc, + value->has_default(), value->get_default_value(), + value->has_implicit(), value->get_implicit_value(), + std::move(arg_help), + value->is_container(), + value->is_boolean()}); +} + +inline +void +Options::add_one_option +( + const std::string& option, + std::shared_ptr details +) +{ + auto in = m_options->emplace(option, details); + + if (!in.second) + { + throw option_exists_error(option); + } +} + +inline +String +Options::help_one_group(const std::string& g) const +{ + typedef std::vector> OptionHelp; + + auto group = m_help.find(g); + if (group == m_help.end()) + { + return ""; + } + + OptionHelp format; + + size_t longest = 0; + + String result; + + if (!g.empty()) + { + result += toLocalString(" " + g + " options:\n"); + } + + for (const auto& o : group->second.options) + { + if (o.is_container && + m_positional_set.find(o.l) != m_positional_set.end() && + !m_show_positional) + { + continue; + } + + auto s = format_option(o); + longest = (std::max)(longest, stringLength(s)); + format.push_back(std::make_pair(s, String())); + } + + longest = (std::min)(longest, static_cast(OPTION_LONGEST)); + + //widest allowed description + auto allowed = size_t{76} - longest - OPTION_DESC_GAP; + + auto fiter = format.begin(); + for (const auto& o : group->second.options) + { + if (o.is_container && + m_positional_set.find(o.l) != m_positional_set.end() && + !m_show_positional) + { + continue; + } + + auto d = format_description(o, longest + OPTION_DESC_GAP, allowed); + + result += fiter->first; + if (stringLength(fiter->first) > longest) + { + result += '\n'; + result += toLocalString(std::string(longest + OPTION_DESC_GAP, ' ')); + } + else + { + result += toLocalString(std::string(longest + OPTION_DESC_GAP - + stringLength(fiter->first), + ' ')); + } + result += d; + result += '\n'; + + ++fiter; + } + + return result; +} + +inline +void +Options::generate_group_help +( + String& result, + const std::vector& print_groups +) const +{ + for (size_t i = 0; i != print_groups.size(); ++i) + { + const String& group_help_text = help_one_group(print_groups[i]); + if (empty(group_help_text)) + { + continue; + } + result += group_help_text; + if (i < print_groups.size() - 1) + { + result += '\n'; + } + } +} + +inline +void +Options::generate_all_groups_help(String& result) const +{ + std::vector all_groups; + all_groups.reserve(m_help.size()); + + for (auto& group : m_help) + { + all_groups.push_back(group.first); + } + + generate_group_help(result, all_groups); +} + +inline +std::string +Options::help(const std::vector& help_groups) const +{ + String result = m_help_string + "\nUsage:\n " + + toLocalString(m_program) + " " + toLocalString(m_custom_help); + + if (m_positional.size() > 0 && m_positional_help.size() > 0) { + result += " " + toLocalString(m_positional_help); + } + + result += "\n\n"; + + if (help_groups.size() == 0) + { + generate_all_groups_help(result); + } + else + { + generate_group_help(result, help_groups); + } + + return toUTF8String(result); +} + +inline +const std::vector +Options::groups() const +{ + std::vector g; + + std::transform( + m_help.begin(), + m_help.end(), + std::back_inserter(g), + [] (const std::map::value_type& pair) + { + return pair.first; + } + ); + + return g; +} + +inline +const HelpGroupDetails& +Options::group_help(const std::string& group) const +{ + return m_help.at(group); +} + +} + +#endif //CXXOPTS_HPP_INCLUDED -- GitLab From f6db0ed67728d76676cb9bd643f7fa81af6acc11 Mon Sep 17 00:00:00 2001 From: Camille Perin Date: Tue, 9 Mar 2021 11:01:15 +0100 Subject: [PATCH 004/194] fix segv --- java/java/src/org/opengroup/openvds/JniPointer.java | 2 +- .../org/opengroup/openvds/VolumeDataChannelDescriptor.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/java/java/src/org/opengroup/openvds/JniPointer.java b/java/java/src/org/opengroup/openvds/JniPointer.java index 95d678c5..3e162aa0 100644 --- a/java/java/src/org/opengroup/openvds/JniPointer.java +++ b/java/java/src/org/opengroup/openvds/JniPointer.java @@ -29,7 +29,7 @@ import java.util.logging.Logger; */ public abstract class JniPointer { - static final String JNI_LIB_NAME = "openvds-javacppd"; + static final String JNI_LIB_NAME = "openvds-javacpp"; private static final Logger LOGGER = Logger.getLogger(JniPointer.class.getName()); private static final String ERR_LIBRARY = "JNI library load failed"; diff --git a/java/java/src/org/opengroup/openvds/VolumeDataChannelDescriptor.java b/java/java/src/org/opengroup/openvds/VolumeDataChannelDescriptor.java index 3dab388e..b7dfba66 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataChannelDescriptor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataChannelDescriptor.java @@ -126,6 +126,10 @@ public class VolumeDataChannelDescriptor { private float integerScale; private float integerOffset; + private VolumeDataChannelDescriptor(){ + // Used by c++ + } + public VolumeDataChannelDescriptor( Format format, Components components, -- GitLab From f28c7e21d5e38662eb5bc1200b0b21d108608863 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Tue, 30 Mar 2021 15:49:52 +0200 Subject: [PATCH 005/194] Bug fix : add default constructor in VolumeDataAxisDescriptor class. --- .../src/org/opengroup/openvds/VolumeDataAxisDescriptor.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/java/src/org/opengroup/openvds/VolumeDataAxisDescriptor.java b/java/java/src/org/opengroup/openvds/VolumeDataAxisDescriptor.java index 6d160d4a..9b9ecd16 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataAxisDescriptor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataAxisDescriptor.java @@ -28,6 +28,11 @@ public class VolumeDataAxisDescriptor { private float coordinateMin; private float coordinateMax; + /** + * Default constructor Needed by JNI + */ + private VolumeDataAxisDescriptor() { } + public VolumeDataAxisDescriptor(int numSamples, String name, String unit, float coordinateMin, float coordinateMax) { this.numSamples = numSamples; this.name = name; -- GitLab From 9a9954a39325a1f88061e4845d0f1f379e6e4245 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Thu, 1 Apr 2021 18:06:06 +0200 Subject: [PATCH 006/194] MetaDataContainer : create java/cpp/unit test --- java/CMakeLists.txt | 2 + java/cpp/src/MetadataContainer.cpp | 181 ++++++++++++++++ .../opengroup/openvds/MetadataContainer.java | 198 ++++++++++++++++++ .../openvds/MetaDataContainerTest.java | 23 ++ 4 files changed, 404 insertions(+) create mode 100644 java/cpp/src/MetadataContainer.cpp create mode 100644 java/java/src/org/opengroup/openvds/MetadataContainer.java create mode 100644 java/java/test/org/opengroup/openvds/MetaDataContainerTest.java diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index bfd86991..c3a02dd9 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -28,6 +28,7 @@ set(JAVA_SOURCE_FILES java/src/org/opengroup/openvds/JniPointer.java java/src/org/opengroup/openvds/JniPointerWithoutDeletion.java java/src/org/opengroup/openvds/MemoryVdsGenerator.java + java/src/org/opengroup/openvds/MetadataContainer.java java/src/org/opengroup/openvds/MetadataKey.java java/src/org/opengroup/openvds/MetadataReadAccess.java java/src/org/opengroup/openvds/MetadataType.java @@ -103,6 +104,7 @@ add_library(openvds-javacpp cpp/src/CommonJni.cpp cpp/src/JniPointer.cpp cpp/src/MemoryVdsGenerator.cpp + cpp/src/MetadataContainer.cpp cpp/src/MetadataReadAccess.cpp cpp/src/OpenVDSJava.cpp cpp/src/QuantizingValueConverter_FloatToByte.cpp diff --git a/java/cpp/src/MetadataContainer.cpp b/java/cpp/src/MetadataContainer.cpp new file mode 100644 index 00000000..8f78e80c --- /dev/null +++ b/java/cpp/src/MetadataContainer.cpp @@ -0,0 +1,181 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +using namespace OpenVDS; + +#ifdef __cplusplus +extern "C" { +#endif + inline MetadataContainer* GetAccess( jlong handle ) { + return (MetadataContainer*)CheckHandle( handle ); + } + + /* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpCreateMetadataContainerHandle + * Signature: ()J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_MetadataContainer_cpCreateMetadataContainerHandle + (JNIEnv * env, jclass) + { + try { + MetadataContainer* container = new MetadataContainer(); + return reinterpret_cast(container); + } + CATCH_EXCEPTIONS_FOR_JAVA; + + return -1L; + } + + /* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpDeleteHandle + * Signature: (J)J + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpDeleteHandle + (JNIEnv * env, jclass, jlong handle) { + try { + delete GetAccess( handle ); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataInt + * Signature: (JLjava/lang/String;Ljava/lang/String;I)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataInt + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jint value) + { + try { + GetAccess( handle )->SetMetadataInt( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), value); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataIntVector2 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector2 +// (JNIEnv *, jclass, jlong, jstring, jstring, jintArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataIntVector3 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector3 +// (JNIEnv *, jclass, jlong, jstring, jstring, jintArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataIntVector4 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector4 +// (JNIEnv *, jclass, jlong, jstring, jstring, jintArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataFloat +// * Signature: (JLjava/lang/String;Ljava/lang/String;F)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloat +// (JNIEnv *, jclass, jlong, jstring, jstring, jfloat); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataFloatVector2 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector2 +// (JNIEnv *, jclass, jlong, jstring, jstring, jfloatArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataFloatVector3 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector3 +// (JNIEnv *, jclass, jlong, jstring, jstring, jfloatArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataFloatVector4 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector4 +// (JNIEnv *, jclass, jlong, jstring, jstring, jfloatArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataDouble +// * Signature: (JLjava/lang/String;Ljava/lang/String;D)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDouble +// (JNIEnv *, jclass, jlong, jstring, jstring, jdouble); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataDoubleVector2 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector2 +// (JNIEnv *, jclass, jlong, jstring, jstring, jdoubleArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataDoubleVector3 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector3 +// (JNIEnv *, jclass, jlong, jstring, jstring, jdoubleArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataDoubleVector4 +// * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector4 +// (JNIEnv *, jclass, jlong, jstring, jstring, jdoubleArray); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataString +// * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataString +// (JNIEnv *, jclass, jlong, jstring, jstring, jstring); +// +///* +// * Class: org_opengroup_openvds_MetadataContainer +// * Method: cpSetMetadataKeys +// * Signature: (J[Lorg/opengroup/openvds/MetadataKey;)V +// */ +//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataKeys +// (JNIEnv *, jclass, jlong, jobjectArray); + +#ifdef __cplusplus +} +#endif diff --git a/java/java/src/org/opengroup/openvds/MetadataContainer.java b/java/java/src/org/opengroup/openvds/MetadataContainer.java new file mode 100644 index 00000000..430bec5e --- /dev/null +++ b/java/java/src/org/opengroup/openvds/MetadataContainer.java @@ -0,0 +1,198 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.openvds; + +import java.util.HashMap; +import java.util.Map; + +public class MetadataContainer extends MetadataReadAccess { + + private static native long cpCreateMetadataContainerHandle(); + + private static native void cpDeleteHandle(long handle); + + private static native void cpSetMetadataInt(long handle, String category, String name, int value); + + private static native void cpSetMetadataIntVector2(long handle, String category, String name, int[] value); + + private static native void cpSetMetadataIntVector3(long handle, String category, String name, int[] value); + + private static native void cpSetMetadataIntVector4(long handle, String category, String name, int[] value); + + private static native void cpSetMetadataFloat(long handle, String category, String name, float value); + + private static native void cpSetMetadataFloatVector2(long handle, String category, String name, float[] value); + + private static native void cpSetMetadataFloatVector3(long handle, String category, String name, float[] value); + + private static native void cpSetMetadataFloatVector4(long handle, String category, String name, float[] value); + + private static native void cpSetMetadataDouble(long handle, String category, String name, double value); + + private static native void cpSetMetadataDoubleVector2(long handle, String category, String name, double[] value); + + private static native void cpSetMetadataDoubleVector3(long handle, String category, String name, double[] value); + + private static native void cpSetMetadataDoubleVector4(long handle, String category, String name, double[] value); + + private static native void cpSetMetadataString(long handle, String category, String name, String value); + + private static native void cpSetMetadataKeys(long handle, MetadataKey[] keys); + + public MetadataContainer(long handle) { + super(handle); + } + + public MetadataContainer() { + super(cpCreateMetadataContainerHandle()); + setOwnHandle(true); + } + + // Called by JniPointer.release() + @Override + protected synchronized void deleteHandle() { + cpDeleteHandle(_handle); + } + + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataInt(String category, String name, int value) { + cpSetMetadataInt(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataIntVector2(String category, String name, int[] value) { + cpSetMetadataIntVector2(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataIntVector3(String category, String name, int[] value) { + cpSetMetadataIntVector3(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataIntVector4(String category, String name, int[] value) { + cpSetMetadataIntVector4(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataFloat(String category, String name, float value) { + cpSetMetadataFloat(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataFloatVector2(String category, String name, float[] value) { + cpSetMetadataFloatVector2(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataFloatVector3(String category, String name, float[] value) { + cpSetMetadataFloatVector3(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataFloatVector4(String category, String name, float[] value) { + cpSetMetadataFloatVector4(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataDouble(String category, String name, double value) { + cpSetMetadataDouble(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataDoubleVector2(String category, String name, double[] value) { + cpSetMetadataDoubleVector2(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataDoubleVector3(String category, String name, double[] value) { + cpSetMetadataDoubleVector3(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataDoubleVector4(String category, String name, double[] value) { + cpSetMetadataDoubleVector4(_handle, category, name, value); + } + + /** + * @param category + * @param name + * @param value + */ + public void setMetadataString(String category, String name, String value) { + cpSetMetadataString(_handle, category, name, value); + } + + /** + * Sets an array of metadata keys + * @param keys + */ + public void setMetadataKeys(MetadataKey[] keys) { + cpSetMetadataKeys(_handle, keys); + } + +} \ No newline at end of file diff --git a/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java b/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java new file mode 100644 index 00000000..042ce65b --- /dev/null +++ b/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java @@ -0,0 +1,23 @@ +package org.opengroup.openvds; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +public class MetaDataContainerTest { + @Test + void testMetadataContainer() { + // creates object + MetadataContainer container = new MetadataContainer(); + + // set values + int singleInt = 1337; + container.setMetadataInt("CategoryInt", "intMetaData", singleInt); + + // get values + int readSingleInt = container.getMetadataInt("CategoryInt", "intMetaData"); + + // check equality + assertEquals(singleInt, readSingleInt); + } +} -- GitLab From 63f7910f98b902b7f4248e47284a210d84f01b45 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Tue, 6 Apr 2021 11:16:32 +0200 Subject: [PATCH 007/194] VdsError structure : java/cpp/test --- java/CMakeLists.txt | 2 + java/cpp/src/VdsError.cpp | 125 ++++++++++++++++++ .../src/org/opengroup/openvds/OpenVDS.java | 17 ++- .../src/org/opengroup/openvds/VdsError.java | 47 +++++++ .../org/opengroup/openvds/VdsErrorTest.java | 25 ++++ 5 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 java/cpp/src/VdsError.cpp create mode 100644 java/java/src/org/opengroup/openvds/VdsError.java create mode 100644 java/java/test/org/opengroup/openvds/VdsErrorTest.java diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index c3a02dd9..9ee863f0 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -37,6 +37,7 @@ set(JAVA_SOURCE_FILES java/src/org/opengroup/openvds/OpenOptions.java java/src/org/opengroup/openvds/OpenVDS.java java/src/org/opengroup/openvds/QuantizingValueConverter_FloatToByte.java + java/src/org/opengroup/openvds/VdsError.java java/src/org/opengroup/openvds/VdsHandle.java java/src/org/opengroup/openvds/VDSFileOpenOptions.java java/src/org/opengroup/openvds/VDSProduceStatus.java @@ -109,6 +110,7 @@ add_library(openvds-javacpp cpp/src/OpenVDSJava.cpp cpp/src/QuantizingValueConverter_FloatToByte.cpp cpp/src/VariousJavaTests.cpp + cpp/src/VdsError.cpp cpp/src/VdsHandle.cpp cpp/src/VolumeDataAccessManager.cpp cpp/src/VolumeDataAccessor.cpp diff --git a/java/cpp/src/VdsError.cpp b/java/cpp/src/VdsError.cpp new file mode 100644 index 00000000..9cfae8be --- /dev/null +++ b/java/cpp/src/VdsError.cpp @@ -0,0 +1,125 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +using namespace OpenVDS; + +#ifdef __cplusplus +extern "C" { +#endif + +inline Error* GetError( jlong handle ) { + return (Error*)CheckHandle( handle ); +} + +/* + * Class: org_opengroup_openvds_VdsError + * Method: cpCreateErrorHandle + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VdsError_cpCreateErrorHandle + (JNIEnv * env, jclass) +{ + try { + Error *error = new Error(); + return reinterpret_cast(error); + } + CATCH_EXCEPTIONS_FOR_JAVA; + + return -1L; +} + +/* + * Class: org_opengroup_openvds_VdsError + * Method: cpDeleteHandle + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_VdsError_cpDeleteHandle + (JNIEnv * env, jclass, jlong handle) +{ + try { + delete &GetError( handle )->string; + delete GetError( handle ); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_VdsError + * Method: cpSetErrorCode + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_VdsError_cpSetErrorCode + (JNIEnv * env, jclass, jlong handle, jint errorCode) +{ + try { + GetError( handle )->code = errorCode; + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_VdsError + * Method: cpSetErrorMessage + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_VdsError_cpSetErrorMessage + (JNIEnv * env, jclass, jlong handle, jstring errorMsg) +{ + try { + GetError( handle )->string = JStringToString( env, errorMsg ).c_str(); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_VdsError + * Method: cpGetErrorCode + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VdsError_cpGetErrorCode + (JNIEnv * env, jclass, jlong handle) +{ + try { + return GetError(handle)->code; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; +} + +/* + * Class: org_opengroup_openvds_VdsError + * Method: cpGetErrorMessage + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_opengroup_openvds_VdsError_cpGetErrorMessage + (JNIEnv * env, jclass, jlong handle) +{ + try { + return NewJString(env, GetError(handle)->string); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; +} + + +#ifdef __cplusplus +} +#endif diff --git a/java/java/src/org/opengroup/openvds/OpenVDS.java b/java/java/src/org/opengroup/openvds/OpenVDS.java index ca8a92f7..2ffe0857 100644 --- a/java/java/src/org/opengroup/openvds/OpenVDS.java +++ b/java/java/src/org/opengroup/openvds/OpenVDS.java @@ -18,8 +18,9 @@ package org.opengroup.openvds; import java.io.IOException; +import java.util.List; -public class OpenVDS extends VdsHandle{ +public class OpenVDS extends VdsHandle { private static native long cpOpenAWS(String bucket, String key, String region, String endpointoverhide) throws IOException; private static native long cpOpenAzure(String pConnectionString, String pContainer, String pBlob, @@ -33,6 +34,11 @@ public class OpenVDS extends VdsHandle{ private static native long cpOpenVDSFile(String filePath) throws IOException; + private static native long cpCreate(OpenOptions options, VolumeDataLayoutDescriptor layoutDescriptor, + VolumeDataAxisDescriptor[] axisDescriptors, + VolumeDataChannelDescriptor[] channelDescriptors, + MetadataContainer mdContainer, VdsError error) throws IOException; + private static native long cpCreateAzure(String pConnectionString, String pContainer, String pBlob, int pParallelismFactor, int pMaxExecutionTime, VolumeDataLayoutDescriptor ld, VolumeDataAxisDescriptor[] vda, @@ -184,6 +190,15 @@ public class OpenVDS extends VdsHandle{ ld, vda, vdc, md), true); } + public static OpenVDS create(OpenOptions options, VolumeDataLayoutDescriptor layoutDescriptor, + VolumeDataAxisDescriptor[] axisDescriptors, + VolumeDataChannelDescriptor[] channelDescriptors, + MetadataContainer mdContainer, VdsError error) throws IOException { + validateCreateArguments(options, layoutDescriptor, axisDescriptors, channelDescriptors, mdContainer); + + return new OpenVDS(cpCreate(options, layoutDescriptor, axisDescriptors, channelDescriptors, mdContainer, error), true); + } + public static void writeArray(VdsHandle handle, double[] src_data, String channel_name) { cpWriteData_r64(handle, src_data, channel_name); } diff --git a/java/java/src/org/opengroup/openvds/VdsError.java b/java/java/src/org/opengroup/openvds/VdsError.java new file mode 100644 index 00000000..09731619 --- /dev/null +++ b/java/java/src/org/opengroup/openvds/VdsError.java @@ -0,0 +1,47 @@ +package org.opengroup.openvds; + +public class VdsError extends JniPointerWithoutDeletion { + + private static native long cpCreateErrorHandle(); + + private static native void cpDeleteHandle(long handle); + + private static native void cpSetErrorCode(long handle, int code); + + private static native void cpSetErrorMessage(long handle, String message); + + private static native int cpGetErrorCode(long handle); + + private static native String cpGetErrorMessage(long handle); + + public VdsError() { + super(cpCreateErrorHandle()); + setOwnHandle(true); + } + + public VdsError(long handle) { + super(handle); + } + + // Called by JniPointer.release() + @Override + protected synchronized void deleteHandle() { + cpDeleteHandle(_handle); + } + + public int getErrorCode() { + return cpGetErrorCode(_handle); + } + + public void setErrorCode(int errorCode) { + cpSetErrorCode(_handle, errorCode); + } + + public String getMessage() { + return cpGetErrorMessage(_handle); + } + + public void setMessage(String message) { + cpSetErrorMessage(_handle, message); + } +} diff --git a/java/java/test/org/opengroup/openvds/VdsErrorTest.java b/java/java/test/org/opengroup/openvds/VdsErrorTest.java new file mode 100644 index 00000000..441e8970 --- /dev/null +++ b/java/java/test/org/opengroup/openvds/VdsErrorTest.java @@ -0,0 +1,25 @@ +package org.opengroup.openvds; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +public class VdsErrorTest { + + @Test + void testVdsError() { + VdsError error = new VdsError(); + + int code = 43; + String errorMessage = "Error message for error 43"; + + error.setErrorCode(code); + error.setMessage(errorMessage); + + int resCode = error.getErrorCode(); + String resMsg = error.getMessage(); + + assertEquals(resCode, code); + assertEquals(resMsg, errorMessage); + } +} -- GitLab From 881715703b20b1b94790fbf3f41c0cc401f1763c Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Tue, 6 Apr 2021 17:08:20 +0200 Subject: [PATCH 008/194] MetadataContainer : set int/float/double (value or vector) metadata Unit tests for create and set/get metadata --- java/cpp/include/CommonJni.h | 1 + java/cpp/src/CommonJni.cpp | 10 + java/cpp/src/MetadataContainer.cpp | 317 ++++++++++++------ java/cpp/src/OpenVDSJava.cpp | 18 + java/java/demo/CreateVDS.java | 71 ++-- .../opengroup/openvds/MetadataContainer.java | 43 ++- .../src/org/opengroup/openvds/OpenVDS.java | 9 - .../org/opengroup/openvds/CreateVDSTest.java | 1 + .../openvds/MetaDataContainerTest.java | 252 ++++++++++++++ 9 files changed, 565 insertions(+), 157 deletions(-) diff --git a/java/cpp/include/CommonJni.h b/java/cpp/include/CommonJni.h index 980e6155..11ef5f8d 100644 --- a/java/cpp/include/CommonJni.h +++ b/java/cpp/include/CommonJni.h @@ -41,6 +41,7 @@ std::vector JArrayToVector( JNIEnv* env, jbyteArray jArr, int start, int l std::vector JArrayToVector( JNIEnv* env, jshortArray jArr ); std::vector JArrayToVector( JNIEnv* env, jintArray jArr ); std::vector JArrayToVector( JNIEnv* env, jfloatArray jArr ); +std::vector JArrayToVector( JNIEnv* env, jdoubleArray jArr ); jbyteArray NewJByteArray( JNIEnv* env, const std::string& str ); jstring NewJString( JNIEnv* env, const char* str ); diff --git a/java/cpp/src/CommonJni.cpp b/java/cpp/src/CommonJni.cpp index f8fd2006..698238b7 100644 --- a/java/cpp/src/CommonJni.cpp +++ b/java/cpp/src/CommonJni.cpp @@ -117,6 +117,16 @@ std::vector JArrayToVector( JNIEnv* env, jfloatArray jArr ) { return arr; } +std::vector JArrayToVector( JNIEnv* env, jdoubleArray jArr ) { + if( !jArr ) + return std::vector(); + if( sizeof( jdouble ) != sizeof( double ) ) + ThrowJavaException( env, "sizeof(jdouble)!=sizeof(double)" ); + jsize len = env->GetArrayLength( jArr ); + std::vector arr( len ); + env->GetDoubleArrayRegion( jArr, 0, len, (jdouble*)arr.data() ); + return arr; +} jstring NewJString( JNIEnv* env, const char* str ) { if( !str || !*str ) diff --git a/java/cpp/src/MetadataContainer.cpp b/java/cpp/src/MetadataContainer.cpp index 8f78e80c..d99ca48b 100644 --- a/java/cpp/src/MetadataContainer.cpp +++ b/java/cpp/src/MetadataContainer.cpp @@ -71,110 +71,219 @@ extern "C" { } CATCH_EXCEPTIONS_FOR_JAVA; } -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataIntVector2 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector2 -// (JNIEnv *, jclass, jlong, jstring, jstring, jintArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataIntVector3 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector3 -// (JNIEnv *, jclass, jlong, jstring, jstring, jintArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataIntVector4 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector4 -// (JNIEnv *, jclass, jlong, jstring, jstring, jintArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataFloat -// * Signature: (JLjava/lang/String;Ljava/lang/String;F)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloat -// (JNIEnv *, jclass, jlong, jstring, jstring, jfloat); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataFloatVector2 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector2 -// (JNIEnv *, jclass, jlong, jstring, jstring, jfloatArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataFloatVector3 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector3 -// (JNIEnv *, jclass, jlong, jstring, jstring, jfloatArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataFloatVector4 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector4 -// (JNIEnv *, jclass, jlong, jstring, jstring, jfloatArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataDouble -// * Signature: (JLjava/lang/String;Ljava/lang/String;D)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDouble -// (JNIEnv *, jclass, jlong, jstring, jstring, jdouble); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataDoubleVector2 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector2 -// (JNIEnv *, jclass, jlong, jstring, jstring, jdoubleArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataDoubleVector3 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector3 -// (JNIEnv *, jclass, jlong, jstring, jstring, jdoubleArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataDoubleVector4 -// * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector4 -// (JNIEnv *, jclass, jlong, jstring, jstring, jdoubleArray); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataString -// * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataString -// (JNIEnv *, jclass, jlong, jstring, jstring, jstring); -// -///* -// * Class: org_opengroup_openvds_MetadataContainer -// * Method: cpSetMetadataKeys -// * Signature: (J[Lorg/opengroup/openvds/MetadataKey;)V -// */ -//JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataKeys -// (JNIEnv *, jclass, jlong, jobjectArray); + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataIntVector2 + * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector2 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jintArray vec2i) +{ + try { + std::vector vec = JArrayToVector(env, vec2i); + IntVector2 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + GetAccess( handle )->SetMetadataIntVector2( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataIntVector3 + * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector3 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jintArray vec3i) +{ + try { + std::vector vec = JArrayToVector(env, vec3i); + IntVector3 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + vdsVec[2] = vec[2]; + GetAccess( handle )->SetMetadataIntVector3( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataIntVector4 + * Signature: (JLjava/lang/String;Ljava/lang/String;[I)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataIntVector4 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jintArray vec4i) +{ + try { + std::vector vec = JArrayToVector(env, vec4i); + IntVector4 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + vdsVec[2] = vec[2]; + vdsVec[3] = vec[3]; + GetAccess( handle )->SetMetadataIntVector4( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataFloat + * Signature: (JLjava/lang/String;Ljava/lang/String;F)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloat + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jfloat value) +{ + try { + GetAccess( handle )->SetMetadataFloat( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), value); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataFloatVector2 + * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector2 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jfloatArray vec2f) +{ + try { + std::vector vec = JArrayToVector(env, vec2f); + FloatVector2 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + GetAccess( handle )->SetMetadataFloatVector2( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataFloatVector3 + * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector3 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jfloatArray vec3f) +{ + try { + std::vector vec = JArrayToVector(env, vec3f); + FloatVector3 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + vdsVec[2] = vec[2]; + GetAccess( handle )->SetMetadataFloatVector3( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataFloatVector4 + * Signature: (JLjava/lang/String;Ljava/lang/String;[F)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataFloatVector4 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jfloatArray vec4f) +{ + try { + std::vector vec = JArrayToVector(env, vec4f); + FloatVector4 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + vdsVec[2] = vec[2]; + vdsVec[3] = vec[3]; + GetAccess( handle )->SetMetadataFloatVector4( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataDouble + * Signature: (JLjava/lang/String;Ljava/lang/String;D)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDouble + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jdouble value) +{ + try { + GetAccess( handle )->SetMetadataDouble( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), value); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataDoubleVector2 + * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector2 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jdoubleArray vec2d) +{ + try { + std::vector vec = JArrayToVector(env, vec2d); + DoubleVector2 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + GetAccess( handle )->SetMetadataDoubleVector2( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataDoubleVector3 + * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector3 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jdoubleArray vec3d) +{ + try { + std::vector vec = JArrayToVector(env, vec3d); + DoubleVector3 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + vdsVec[2] = vec[2]; + GetAccess( handle )->SetMetadataDoubleVector3( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataDoubleVector4 + * Signature: (JLjava/lang/String;Ljava/lang/String;[D)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataDoubleVector4 + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jdoubleArray vec4d) +{ + try { + std::vector vec = JArrayToVector(env, vec4d); + DoubleVector4 vdsVec; + vdsVec[0] = vec[0]; + vdsVec[1] = vec[1]; + vdsVec[2] = vec[2]; + vdsVec[3] = vec[3]; + GetAccess( handle )->SetMetadataDoubleVector4( JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), vdsVec); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} + +/* + * Class: org_opengroup_openvds_MetadataContainer + * Method: cpSetMetadataString + * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_opengroup_openvds_MetadataContainer_cpSetMetadataString + (JNIEnv * env, jclass, jlong handle, jstring category, jstring name, jstring value) +{ + try { + GetAccess( handle )->SetMetadataString(JStringToString( env, category ).c_str(), JStringToString( env, name ).c_str(), JStringToString(env, value).c_str()); + } + CATCH_EXCEPTIONS_FOR_JAVA; +} #ifdef __cplusplus } diff --git a/java/cpp/src/OpenVDSJava.cpp b/java/cpp/src/OpenVDSJava.cpp index 7dd5eb5c..47afa85e 100644 --- a/java/cpp/src/OpenVDSJava.cpp +++ b/java/cpp/src/OpenVDSJava.cpp @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -177,6 +178,22 @@ getMetadata(JNIEnv *env, jobject md) return reinterpret_cast(CheckHandle(handle)); } +static OpenVDS::MetadataContainer* +getMetadataContainer(JNIEnv *env, jobject mdc) +{ + jclass obj_class = env->GetObjectClass(mdc); + jlong handle = env->CallLongMethod(mdc, env->GetMethodID(obj_class, "handle", "()J")); + return reinterpret_cast(CheckHandle(handle)); +} + +static OpenVDS::Error* +getError(JNIEnv *env, jobject err) +{ + jclass obj_class = env->GetObjectClass(err); + jlong handle = env->CallLongMethod(err, env->GetMethodID(obj_class, "handle", "()J")); + return reinterpret_cast(CheckHandle(handle)); +} + static std::vector getValueDataAxisDescriptors(JNIEnv *env, jobjectArray obj, std::multiset& string_buffer) { @@ -413,3 +430,4 @@ Java_org_opengroup_openvds_OpenVDS_cpCreateConnection(JNIEnv* env, jclass, return (jlong)pVds; } + diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index 70fe6e8d..3bc92280 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -1,9 +1,10 @@ import org.opengroup.openvds.*; +import java.util.ArrayList; import java.util.List; public class CreateVDS { -/** + public static void main(String[] args) { try { process(args); @@ -14,6 +15,7 @@ public class CreateVDS { } static void process(String[] args) throws Exception { + int samplesX = 1000; int samplesY = 1000; int samplesZ = 1000; @@ -28,15 +30,13 @@ public class CreateVDS { VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, brickSize2DMultiplier, lodLevels, false,false,0); - List axisDescriptors; - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "ms", 0.0f, - 4.f)); - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "", - 1932.f, 2536.f)); - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 9985.f, - 10369.f)); + List axisDescriptors = new ArrayList<>(); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "ms", 0.0f,4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1932.f, 2536.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 9985.f,10369.f)); - List channelDescriptors; + List channelDescriptors = new ArrayList<>(); + /** float rangeMin = -0.1234f; float rangeMax = 0.1234f; float intScale; @@ -46,40 +46,38 @@ public class CreateVDS { "Amplitude", "", rangeMin, rangeMax, VolumeDataMapping.DIRECT, 1, VolumeDataChannelDescriptor.Default, 0.f, intScale, intOffset); + */ //OpenVDS::InMemoryOpenOptions options; - VDSFileOpenOptions options = new VDSFileOpenOptions("/mnt/dataDD/tmp/create.vds"); - OpenVDS.Error error; - - MetadataContainer metadataContainer; - metadataContainer.SetMetadataInt("categoryInt", "Int", 123); - metadataContainer.SetMetadataIntVector2("categoryInt", "IntVector2", OpenVDS.IntVector2 (45, 78)); - metadataContainer.SetMetadataIntVector3("categoryInt", "IntVector3", OpenVDS.IntVector3 (45, 78, 72)); - metadataContainer.SetMetadataIntVector4("categoryInt", "IntVector4", OpenVDS.IntVector4 (45, 78, 72, 84)); - metadataContainer.SetMetadataFloat("categoryFloat", "Float", 123.f); - metadataContainer.SetMetadataFloatVector2("categoryFloat", "FloatVector2", OpenVDS::FloatVector2 (45.5f, 78.75f)); - metadataContainer.SetMetadataFloatVector3("categoryFloat", "FloatVector3", - OpenVDS::FloatVector3 (45.5f, 78.75f, 72.75f)); - metadataContainer.SetMetadataFloatVector4("categoryFloat", "FloatVector4", - OpenVDS::FloatVector4 (45.5f, 78.75f, 72.75f, 84.1f)); - metadataContainer.SetMetadataDouble("categoryDouble", "Double", 123.); - metadataContainer.SetMetadataDoubleVector2("categoryDouble", "DoubleVector2", OpenVDS::DoubleVector2 - (45.5, 78.75)); - metadataContainer.SetMetadataDoubleVector3("categoryDouble", "DoubleVector3", - OpenVDS::DoubleVector3 (45.5, 78.75, 72.75)); - metadataContainer.SetMetadataDoubleVector4("categoryDouble", "DoubleVector4", - OpenVDS::DoubleVector4 (45.5, 78.75, 72.75, 84.1)); - metadataContainer.SetMetadataString("categoryString", "String", std::string ("Test string")); -//metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); - - VdsHandle vds = OpenVDS.create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, - error); + VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/create.vds"); + VdsError error; + + MetadataContainer metadataContainer = new MetadataContainer(); + metadataContainer.setMetadataInt("categoryInt", "Int", 123); + metadataContainer.setMetadataIntVector2("categoryInt", "IntVector2", new int[] {45, 78}); + metadataContainer.setMetadataIntVector3("categoryInt", "IntVector3", new int[] {45, 78, 72}); + metadataContainer.setMetadataIntVector4("categoryInt", "IntVector4", new int[] {45, 78, 72, 84}); + metadataContainer.setMetadataFloat("categoryFloat", "Float", 123.f); + metadataContainer.setMetadataFloatVector2("categoryFloat", "FloatVector2", new float[] {45.5f, 78.75f}); + metadataContainer.setMetadataFloatVector3("categoryFloat", "FloatVector3", new float[] {45.5f, 78.75f, 72.75f}); + metadataContainer.setMetadataFloatVector4("categoryFloat", "FloatVector4", new float[] {45.5f, 78.75f, 72.75f, 84.1f}); + metadataContainer.setMetadataDouble("categoryDouble", "Double", 123.); + metadataContainer.setMetadataDoubleVector2("categoryDouble", "DoubleVector2", new double[] {45.5, 78.75}); + metadataContainer.setMetadataDoubleVector3("categoryDouble", "DoubleVector3", new double[] {45.5, 78.75, 72.75}); + metadataContainer.setMetadataDoubleVector4("categoryDouble", "DoubleVector4", new double[] {45.5, 78.75, 72.75, 84.1}); + metadataContainer.setMetadataString("categoryString", "String", "Test string"); + //metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); + + VdsHandle vds = OpenVDS.create(options, layoutDescriptor, + axisDescriptors.toArray(new VolumeDataAxisDescriptor[0]), + channelDescriptors.toArray(new VolumeDataChannelDescriptor[0]), metadataContainer); + VolumeDataLayout layout = vds.getLayout(); //ASSERT_TRUE(layout); VolumeDataAccessManager accessManager = vds.getAccessManager(); //ASSERT_TRUE(accessManager); - + /** int channel = 0; VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor(layout, DimensionsND.DIMENSIONS_012, channel, 0, 100, VolumeDataAccessManager.AccessMode.CREATE) @@ -159,4 +157,5 @@ public class CreateVDS { } } */ + } } diff --git a/java/java/src/org/opengroup/openvds/MetadataContainer.java b/java/java/src/org/opengroup/openvds/MetadataContainer.java index 430bec5e..e156e11c 100644 --- a/java/java/src/org/opengroup/openvds/MetadataContainer.java +++ b/java/java/src/org/opengroup/openvds/MetadataContainer.java @@ -52,12 +52,17 @@ public class MetadataContainer extends MetadataReadAccess { private static native void cpSetMetadataString(long handle, String category, String name, String value); - private static native void cpSetMetadataKeys(long handle, MetadataKey[] keys); - + /** + * Constructor around existing JNI object + * @param handle jni pointer to existing container + */ public MetadataContainer(long handle) { super(handle); } + /** + * Creates new MetadataContainer + */ public MetadataContainer() { super(cpCreateMetadataContainerHandle()); setOwnHandle(true); @@ -85,6 +90,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataIntVector2(String category, String name, int[] value) { + checkArrayArgument(value, 2); cpSetMetadataIntVector2(_handle, category, name, value); } @@ -94,6 +100,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataIntVector3(String category, String name, int[] value) { + checkArrayArgument(value, 3); cpSetMetadataIntVector3(_handle, category, name, value); } @@ -103,6 +110,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataIntVector4(String category, String name, int[] value) { + checkArrayArgument(value, 4); cpSetMetadataIntVector4(_handle, category, name, value); } @@ -121,6 +129,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataFloatVector2(String category, String name, float[] value) { + checkArrayArgument(value, 2); cpSetMetadataFloatVector2(_handle, category, name, value); } @@ -130,6 +139,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataFloatVector3(String category, String name, float[] value) { + checkArrayArgument(value, 3); cpSetMetadataFloatVector3(_handle, category, name, value); } @@ -139,6 +149,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataFloatVector4(String category, String name, float[] value) { + checkArrayArgument(value, 4); cpSetMetadataFloatVector4(_handle, category, name, value); } @@ -157,6 +168,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataDoubleVector2(String category, String name, double[] value) { + checkArrayArgument(value, 2); cpSetMetadataDoubleVector2(_handle, category, name, value); } @@ -166,6 +178,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataDoubleVector3(String category, String name, double[] value) { + checkArrayArgument(value, 3); cpSetMetadataDoubleVector3(_handle, category, name, value); } @@ -175,6 +188,7 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataDoubleVector4(String category, String name, double[] value) { + checkArrayArgument(value, 4); cpSetMetadataDoubleVector4(_handle, category, name, value); } @@ -184,15 +198,28 @@ public class MetadataContainer extends MetadataReadAccess { * @param value */ public void setMetadataString(String category, String name, String value) { + if (value == null) { + throw new IllegalArgumentException("Null String Metadata."); + } cpSetMetadataString(_handle, category, name, value); } - /** - * Sets an array of metadata keys - * @param keys - */ - public void setMetadataKeys(MetadataKey[] keys) { - cpSetMetadataKeys(_handle, keys); + + private void checkArrayArgument(int[] array, int expectedSize) { + if (array == null || array.length != expectedSize) { + throw new IllegalArgumentException("Wrong IntVector parameter size, expected " + expectedSize + " got " + (array == null ? "null" : array.length)); + } } + private void checkArrayArgument(float[] array, int expectedSize) { + if (array == null || array.length != expectedSize) { + throw new IllegalArgumentException("Wrong FloatVector parameter size, expected 2, got " + (array == null ? "null" : array.length)); + } + } + + private void checkArrayArgument(double[] array, int expectedSize) { + if (array == null || array.length != expectedSize) { + throw new IllegalArgumentException("Wrong DoubleVector parameter size, expected 2, got " + (array == null ? "null" : array.length)); + } + } } \ No newline at end of file diff --git a/java/java/src/org/opengroup/openvds/OpenVDS.java b/java/java/src/org/opengroup/openvds/OpenVDS.java index 2ffe0857..4dc32102 100644 --- a/java/java/src/org/opengroup/openvds/OpenVDS.java +++ b/java/java/src/org/opengroup/openvds/OpenVDS.java @@ -190,15 +190,6 @@ public class OpenVDS extends VdsHandle { ld, vda, vdc, md), true); } - public static OpenVDS create(OpenOptions options, VolumeDataLayoutDescriptor layoutDescriptor, - VolumeDataAxisDescriptor[] axisDescriptors, - VolumeDataChannelDescriptor[] channelDescriptors, - MetadataContainer mdContainer, VdsError error) throws IOException { - validateCreateArguments(options, layoutDescriptor, axisDescriptors, channelDescriptors, mdContainer); - - return new OpenVDS(cpCreate(options, layoutDescriptor, axisDescriptors, channelDescriptors, mdContainer, error), true); - } - public static void writeArray(VdsHandle handle, double[] src_data, String channel_name) { cpWriteData_r64(handle, src_data, channel_name); } diff --git a/java/java/test/org/opengroup/openvds/CreateVDSTest.java b/java/java/test/org/opengroup/openvds/CreateVDSTest.java index 87936553..3574c491 100644 --- a/java/java/test/org/opengroup/openvds/CreateVDSTest.java +++ b/java/java/test/org/opengroup/openvds/CreateVDSTest.java @@ -69,6 +69,7 @@ public class CreateVDSTest { } } + @Test(expectedExceptions = IllegalArgumentException.class) public void testException1() { try { diff --git a/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java b/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java index 042ce65b..967bbd15 100644 --- a/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java +++ b/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java @@ -1,10 +1,46 @@ package org.opengroup.openvds; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; public class MetaDataContainerTest { + + public String url; + public VolumeDataLayoutDescriptor ld; + public VolumeDataAxisDescriptor[] vda; + public VolumeDataChannelDescriptor[] vdc; + public MetadataReadAccess md; + public MemoryVdsGenerator vds; + + @BeforeClass + public void init() { + vds = new MemoryVdsGenerator(16, 16, 16, VolumeDataChannelDescriptor.Format.FORMAT_U8); + url = "inmemory://create_test"; + VolumeDataLayout volumeDataLayout = vds.getLayout(); + + int nbChannel = volumeDataLayout.getChannelCount(); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + + for (VolumeDataLayoutDescriptor.LODLevels l : VolumeDataLayoutDescriptor.LODLevels.values()) { + for (int channel = 0; channel < nbChannel; channel++) { + for (DimensionsND dimGroup : DimensionsND.values()) { + VDSProduceStatus vdsProduceStatus = accessManager.getVDSProduceStatus(volumeDataLayout, dimGroup, l.ordinal(), channel); + } + } + } + + vda = new VolumeDataAxisDescriptor[] {volumeDataLayout.getAxisDescriptor(0), + volumeDataLayout.getAxisDescriptor(1), + volumeDataLayout.getAxisDescriptor(2)}; + vdc = new VolumeDataChannelDescriptor[] {volumeDataLayout.getChannelDescriptor(0)}; + + md = volumeDataLayout; + ld = volumeDataLayout.getLayoutDescriptor(); + } + @Test void testMetadataContainer() { // creates object @@ -20,4 +56,220 @@ public class MetaDataContainerTest { // check equality assertEquals(singleInt, readSingleInt); } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckIntV2() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataIntVector2("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckIntV3() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataIntVector3("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckIntV4() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataIntVector4("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckFloatV2() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataFloatVector2("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckFloatV3() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataFloatVector3("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckFloatV4() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataFloatVector4("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckDoubleV2() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataDoubleVector2("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckDoubleV3() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataDoubleVector3("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullCheckDoubleV4() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataDoubleVector4("categoryArray", "nullArray", null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckIntV2() { + int[] vec3i = new int[] {54, 76, 99}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataIntVector2("categoryInt", "IntV2", vec3i); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckIntV3() { + int[] vec2i = new int[] {54, 76}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataIntVector3("categoryInt", "IntV3", vec2i); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckIntV4() { + int[] vec2i = new int[] {54, 76}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataIntVector4("categoryInt", "IntV3", vec2i); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckFloatV2() { + float[] vec3f = new float[] {54f, 76f, 99f}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataFloatVector2("categoryFloat", "FloatV2", vec3f); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckFloatV3() { + float[] vec2f = new float[] {54f, 76f}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataFloatVector3("categoryFloat", "FloatV3", vec2f); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckFloatV4() { + float[] vec5f = new float[] {54f, 76f, 55f, 50f, 88f}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataFloatVector4("categoryFloat", "FloatV4", vec5f); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckDoubleV2() { + double[] vec3d = new double[] {54d, 76d, 99d}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataDoubleVector2("categoryDouble", "DoubleV2", vec3d); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckDoubleV3() { + double[] vec2f = new double[] {54d, 76d}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataDoubleVector3("categoryDouble", "DoubleV3", vec2f); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSizeCheckDoubleV4() { + double[] vec5d = new double[] {54d, 76d, 55d, 50d, 88d}; + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataDoubleVector4("categoryDouble", "DoubleV4", vec5d); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNullMetadataString() { + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataString("categoryString", "nullMetaData", null); + } + + @Test + public void testCreateVDSWithMetaData() { + try { + int i1 = 1337; + int[] vec2i = new int[] {54, 76}; + int[] vec3i = new int[] {33, 66, 99}; + int[] vec4i = new int[] {11, 22, 44, 88}; + + float f1 = 13.37f; + float[] vec2f = new float[] {54.4f, 76.5f}; + float[] vec3f = new float[] {33.3f, 66.6f, 99.9f}; + float[] vec4f = new float[] {11.1f, 22.2f, 44.4f, 88.8f}; + + double d1 = 26.74d; + double[] vec2d = new double[] {54.45d, 76.67d}; + double[] vec3d = new double[] {33.33d, 666.666d, 999.999d}; + double[] vec4d = new double[] {11.11d, 22.222d, 44.4444d, 88.88888d}; + + String mdString = "Char sequence metadata"; + + MetadataContainer metaData = new MetadataContainer(); + metaData.setMetadataInt("categoryInt", "singleInt", i1); + metaData.setMetadataIntVector2("categoryInt", "IntV2", vec2i); + metaData.setMetadataIntVector3("categoryInt", "IntV3", vec3i); + metaData.setMetadataIntVector4("categoryInt", "IntV4", vec4i); + + metaData.setMetadataFloat("categoryFloat", "singleFloat", f1); + metaData.setMetadataFloatVector2("categoryFloat", "FloatV2", vec2f); + metaData.setMetadataFloatVector3("categoryFloat", "FloatV3", vec3f); + metaData.setMetadataFloatVector4("categoryFloat", "FloatV4", vec4f); + + metaData.setMetadataDouble("categoryDouble", "singleDouble", d1); + metaData.setMetadataDoubleVector2("categoryDouble", "DoubleV2", vec2d); + metaData.setMetadataDoubleVector3("categoryDouble", "DoubleV3", vec3d); + metaData.setMetadataDoubleVector4("categoryDouble", "DoubleV4", vec4d); + + metaData.setMetadataString("categoryString", "String", mdString); + + VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testCreate.vds"); + VdsError vdsError = new VdsError(); + OpenVDS createdVDS = OpenVDS.create(options, ld, vda, vdc, metaData); + + // test meta data + // int + int mdInt = createdVDS.getLayout().getMetadataInt("categoryInt", "singleInt"); + assertEquals(mdInt, i1); + + int[] mdIntVector2 = createdVDS.getLayout().getMetadataIntVector2("categoryInt", "IntV2"); + assertEquals(vec2i, mdIntVector2); + + int[] mdIntVector3 = createdVDS.getLayout().getMetadataIntVector3("categoryInt", "IntV3"); + assertEquals(vec3i, mdIntVector3); + + int[] mdIntVector4 = createdVDS.getLayout().getMetadataIntVector4("categoryInt", "IntV4"); + assertEquals(vec4i, mdIntVector4); + + // float + float mdFloat = createdVDS.getLayout().getMetadataFloat("categoryFloat", "singleFloat"); + assertEquals(mdFloat, f1); + + float[] mdFloatVector2 = createdVDS.getLayout().getMetadataFloatVector2("categoryFloat", "FloatV2"); + assertEquals(vec2f, mdFloatVector2); + + float[] mdFloatVector3 = createdVDS.getLayout().getMetadataFloatVector3("categoryFloat", "FloatV3"); + assertEquals(vec3f, mdFloatVector3); + + float[] mdFloatVector4 = createdVDS.getLayout().getMetadataFloatVector4("categoryFloat", "FloatV4"); + assertEquals(vec4f, mdFloatVector4); + + // double + double mdDouble = createdVDS.getLayout().getMetadataDouble("categoryDouble", "singleDouble"); + assertEquals(mdDouble, d1); + + double[] mdDoubleVector2 = createdVDS.getLayout().getMetadataDoubleVector2("categoryDouble", "DoubleV2"); + assertEquals(vec2d, mdDoubleVector2); + + double[] mdDoubleVector3 = createdVDS.getLayout().getMetadataDoubleVector3("categoryDouble", "DoubleV3"); + assertEquals(vec3d, mdDoubleVector3); + + double[] mdDoubleVector4 = createdVDS.getLayout().getMetadataDoubleVector4("categoryDouble", "DoubleV4"); + assertEquals(vec4d, mdDoubleVector4); + + // String + String mdS = createdVDS.getLayout().getMetadataString("categoryString", "String"); + assertEquals(mdS, mdString); + } + catch (java.io.IOException e) { + System.out.println(e.getMessage()); + fail(); + } + } + } -- GitLab From a8530a5f51d6a476dc0e4633de3a2fc5bfb0c449 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Thu, 8 Apr 2021 18:29:40 +0200 Subject: [PATCH 009/194] VolumeDataPage : beginning of read/write float buffer array --- java/CMakeLists.txt | 4 + java/cpp/src/VolumeDataPage.cpp | 56 +++++- java/cpp/src/VolumeDataPageAccessor.cpp | 79 ++++++++- java/cpp/src/VolumeIndexer3D.cpp | 61 +++++++ java/cpp/src/VolumeIndexerBase.cpp | 163 ++++++++++++++++++ java/java/demo/CreateVDS.java | 127 ++++++++++---- .../openvds/VolumeDataAccessManager.java | 43 ++++- .../org/opengroup/openvds/VolumeDataPage.java | 17 +- .../openvds/VolumeDataPageAccessor.java | 33 +++- .../opengroup/openvds/VolumeIndexer3D.java | 15 ++ .../opengroup/openvds/VolumeIndexerBase.java | 37 ++++ .../opengroup/openvds/PageAccessorTest.java | 139 +++++++++++++++ 12 files changed, 713 insertions(+), 61 deletions(-) create mode 100644 java/cpp/src/VolumeIndexer3D.cpp create mode 100644 java/cpp/src/VolumeIndexerBase.cpp create mode 100644 java/java/src/org/opengroup/openvds/VolumeIndexer3D.java create mode 100644 java/java/src/org/opengroup/openvds/VolumeIndexerBase.java create mode 100644 java/java/test/org/opengroup/openvds/PageAccessorTest.java diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 9ee863f0..2062058b 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -50,6 +50,8 @@ set(JAVA_SOURCE_FILES java/src/org/opengroup/openvds/VolumeDataMapping.java java/src/org/opengroup/openvds/VolumeDataPage.java java/src/org/opengroup/openvds/VolumeDataPageAccessor.java + java/src/org/opengroup/openvds/VolumeIndexerBase.java + java/src/org/opengroup/openvds/VolumeIndexer3D.java java/demo/AWSSliceDumpDemo.java java/demo/OpenVdsDemo.java @@ -117,6 +119,8 @@ add_library(openvds-javacpp cpp/src/VolumeDataLayout.cpp cpp/src/VolumeDataPage.cpp cpp/src/VolumeDataPageAccessor.cpp + cpp/src/VolumeIndexerBase.cpp + cpp/src/VolumeIndexer3D.cpp cpp/src/WriteVolumeData.cpp ) diff --git a/java/cpp/src/VolumeDataPage.cpp b/java/cpp/src/VolumeDataPage.cpp index fdc3fada..26a1f3f2 100644 --- a/java/cpp/src/VolumeDataPage.cpp +++ b/java/cpp/src/VolumeDataPage.cpp @@ -16,17 +16,59 @@ */ #include +#include +#include #ifdef __cplusplus extern "C" { #endif -/* - * Class: org_opengroup_openvds_VolumeDataPage - * Method: cpDeleteHandle - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpDeleteHandle - (JNIEnv *, jclass, jlong); + + inline OpenVDS::VolumeDataPage* GetVolumePage( jlong handle ) { + return (OpenVDS::VolumeDataPage*) CheckHandle( handle ); + } + + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpRelease + * Signature: (J)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpRelease + (JNIEnv * env, jclass, jlong handle) + { + try { + GetVolumePage( handle )->Release(); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpGetWritableFloatBuffer + * Signature: (J[I)[F + */ + JNIEXPORT jfloatArray JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetFloatBuffer + (JNIEnv * env, jclass, jlong handle, jintArray pitchParam) + { + try { + std::vector vecPitch = JArrayToVector(env, pitchParam); + int pitch[OpenVDS::Dimensionality_Max]; + int cMin[OpenVDS::Dimensionality_Max]; + int cMax[OpenVDS::Dimensionality_Max]; + GetVolumePage(handle)->GetMinMax(cMin, cMax); + + int chunk_size_i = cMax[2] - cMin[2]; + int chunk_size_x = cMax[1] - cMin[1]; + int chunk_size_z = cMax[0] - cMin[0]; + + float* readData = reinterpret_cast(GetVolumePage(handle)->GetWritableBuffer(pitch)); + env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); + + int nbElem = chunk_size_i * chunk_size_x * chunk_size_z; + return NewJFloatArray(env, readData, nbElem); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } #ifdef __cplusplus } diff --git a/java/cpp/src/VolumeDataPageAccessor.cpp b/java/cpp/src/VolumeDataPageAccessor.cpp index f80dfd59..d2445196 100644 --- a/java/cpp/src/VolumeDataPageAccessor.cpp +++ b/java/cpp/src/VolumeDataPageAccessor.cpp @@ -16,18 +16,83 @@ */ #include +#include +#include #ifdef __cplusplus extern "C" { #endif -/* - * Class: org_opengroup_openvds_VolumeDataPageAccessor - * Method: cpGetLayout - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetLayout - (JNIEnv *, jclass, jlong); + inline OpenVDS::VolumeDataPageAccessor* GetPageAccessor( jlong handle ) { + return (OpenVDS::VolumeDataPageAccessor*) CheckHandle( handle ); + } + + + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpGetLayout + * Signature: (J)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetLayout + (JNIEnv * env, jclass, jlong handle) + { + try { + const OpenVDS::VolumeDataLayout* layout = GetPageAccessor( handle )->GetLayout(); + return (jlong) layout; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; + } + + + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpGetChunkCount + * Signature: (J)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetChunkCount + (JNIEnv * env, jclass, jlong handle) + { + try { + return GetPageAccessor( handle )->GetChunkCount(); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpCreatePage + * Signature: (JJ)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpCreatePage + (JNIEnv * env, jclass, jlong handle, jlong pageIndex) + { + try { + OpenVDS::VolumeDataPage* volumePage = GetPageAccessor( handle )->CreatePage(pageIndex); + return (jlong) volumePage; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpGetChunkMinMax + * Signature: (JI[I[I)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetChunkMinMax + (JNIEnv * env, jclass, jlong handle, jint chunk, jintArray chunkMin, jintArray chunkMax) + { + try { + int cMin[OpenVDS::Dimensionality_Max]; + int cMax[OpenVDS::Dimensionality_Max]; + GetPageAccessor( handle )->GetChunkMinMax(chunk, cMin, cMax); + env->SetIntArrayRegion(chunkMin, 0, OpenVDS::Dimensionality_Max, cMin); + env->SetIntArrayRegion(chunkMax, 0, OpenVDS::Dimensionality_Max, cMax); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeIndexer3D.cpp b/java/cpp/src/VolumeIndexer3D.cpp new file mode 100644 index 00000000..5c96da3f --- /dev/null +++ b/java/cpp/src/VolumeIndexer3D.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +using namespace OpenVDS; + +#ifdef __cplusplus +extern "C" { +#endif + + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { + return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); + } + + inline OpenVDS::VolumeDataPage *GetVolumePage(jlong handle) { + return (OpenVDS::VolumeDataPage *) CheckHandle(handle); + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpCreateVolumeIndexer3D + * Signature: (Lorg/opengroup/openvds/VolumeDataPage;IILorg/opengroup/openvds/DimensionsND;Lorg/opengroup/openvds/VolumeDataLayout;)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpCreateVolumeIndexer3D + (JNIEnv * env, jclass, jlong vlPageHandle, jint channelIndex, jint lod, jint dimND, jlong layoutHandle) + { + try { + VolumeDataPage* volumeDataPage = GetVolumePage(vlPageHandle); + VolumeDataLayout* layout = GetLayout(layoutHandle); + VolumeIndexer3D* indexer3D = new VolumeIndexer3D(volumeDataPage, channelIndex, lod, (DimensionsND)dimND, layout); + return (jlong)indexer3D; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; + } + +#ifdef __cplusplus +} +#endif + + + diff --git a/java/cpp/src/VolumeIndexerBase.cpp b/java/cpp/src/VolumeIndexerBase.cpp new file mode 100644 index 00000000..4bdf2f9a --- /dev/null +++ b/java/cpp/src/VolumeIndexerBase.cpp @@ -0,0 +1,163 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +using namespace OpenVDS; + +#ifdef __cplusplus +extern "C" { +#endif + + inline VolumeIndexer2D * GetVolumeIndexer2D( jlong handle ) { + return (VolumeIndexer2D*)CheckHandle( handle ); + } + + inline VolumeIndexer3D * GetVolumeIndexer3D( jlong handle ) { + return (VolumeIndexer3D*)CheckHandle( handle ); + } + + inline VolumeIndexer4D * GetVolumeIndexer4D( jlong handle ) { + return (VolumeIndexer4D*)CheckHandle( handle ); + } + + inline VolumeIndexer5D * GetVolumeIndexer5D( jlong handle ) { + return (VolumeIndexer5D*)CheckHandle( handle ); + } + + inline VolumeIndexer6D * GetVolumeIndexer6D( jlong handle ) { + return (VolumeIndexer6D*)CheckHandle( handle ); + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpDeleteHandle + * Signature: (J)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpDeleteHandle + (JNIEnv * env, jclass, jlong handle, jint volumeDimension) + { + try { + switch (volumeDimension) { + case 2: + delete GetVolumeIndexer2D(handle); + break; + case 3: + delete GetVolumeIndexer3D(handle); + break; + case 4: + delete GetVolumeIndexer4D(handle); + break; + case 5: + delete GetVolumeIndexer5D(handle); + break; + case 6: + delete GetVolumeIndexer6D(handle); + break; + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpGetValueRangeMin + * Signature: (JI)F + */ + JNIEXPORT jfloat JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpGetValueRangeMin + (JNIEnv * env, jclass, jlong handle, jint volumeDimension) + { + try { + switch (volumeDimension) { + case 2: + return GetVolumeIndexer2D(handle)->valueRangeMin; + case 3: + return GetVolumeIndexer3D(handle)->valueRangeMin; + case 4: + return GetVolumeIndexer4D(handle)->valueRangeMin; + case 5: + return GetVolumeIndexer5D(handle)->valueRangeMin; + case 6: + return GetVolumeIndexer6D(handle)->valueRangeMin; + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return std::numeric_limits::min(); + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpGetValueRangeMax + * Signature: (JI)F + */ + JNIEXPORT jfloat JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpGetValueRangeMax + (JNIEnv * env, jclass, jlong handle, jint volumeDimension) + { + try { + switch (volumeDimension) { + case 2: + return GetVolumeIndexer2D(handle)->valueRangeMax; + case 3: + return GetVolumeIndexer3D(handle)->valueRangeMax; + case 4: + return GetVolumeIndexer4D(handle)->valueRangeMax; + case 5: + return GetVolumeIndexer5D(handle)->valueRangeMax; + case 6: + return GetVolumeIndexer6D(handle)->valueRangeMax; + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return std::numeric_limits::max(); + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpGetDataBlockNumSamples + * Signature: (JII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpGetDataBlockNumSamples + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jint dim) + { + try { + switch (volumeDimension) { + case 2: + return GetVolumeIndexer2D(handle)->GetDataBlockNumSamples(dim); + case 3: + return GetVolumeIndexer3D(handle)->GetDataBlockNumSamples(dim); + case 4: + return GetVolumeIndexer4D(handle)->GetDataBlockNumSamples(dim); + case 5: + return GetVolumeIndexer5D(handle)->GetDataBlockNumSamples(dim); + case 6: + return GetVolumeIndexer6D(handle)->GetDataBlockNumSamples(dim); + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + +#ifdef __cplusplus +} +#endif + + + diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index 3bc92280..38c94ff2 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -36,17 +36,28 @@ public class CreateVDS { axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 9985.f,10369.f)); List channelDescriptors = new ArrayList<>(); - /** + float rangeMin = -0.1234f; float rangeMax = 0.1234f; - float intScale; - float intOffset; - getScaleOffsetForFormat(rangeMin, rangeMax, true, format, intScale, intOffset); - channelDescriptors.add(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, - "Amplitude", "", rangeMin, rangeMax, - VolumeDataMapping.DIRECT, 1, - VolumeDataChannelDescriptor.Default, 0.f, intScale, intOffset); - */ + float[] scaleOffset = getScaleOffsetForFormat(rangeMin, rangeMax, true, format); + + VolumeDataChannelDescriptor channelDescriptor = new VolumeDataChannelDescriptor(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", + "", + rangeMin, // range min + rangeMax, // range max + VolumeDataMapping.DIRECT, // mapping + 1, // mapped value count + false, // is discrete + true, // is renderable + false, // allow lossy compression + false, // use zip for lossless compresion + true, // use no value + -999.25f, // no value + scaleOffset[0], // integer scale + scaleOffset[1]); // integer offset + channelDescriptors.add(channelDescriptor); + //OpenVDS::InMemoryOpenOptions options; VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/create.vds"); @@ -77,20 +88,29 @@ public class CreateVDS { //ASSERT_TRUE(layout); VolumeDataAccessManager accessManager = vds.getAccessManager(); //ASSERT_TRUE(accessManager); - /** + int channel = 0; - VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor(layout, DimensionsND.DIMENSIONS_012, channel, 0, 100, VolumeDataAccessManager.AccessMode.CREATE) + + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + 0, // lod + channel, // channel + 100, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode //ASSERT_TRUE(pageAccessor); int chunkCount = (int) pageAccessor.getChunkCount(); //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); + for (int i = 0; i < chunkCount; i++) { VolumeDataPage page = pageAccessor.createPage(i); - VolumeIndexer3D outputIndexer(page, 0, 0, DimensionsND.DIMENSIONS_012, layout); + VolumeDataLayoutDescriptor.BrickSize brickSize1 = pageAccessor.getLayout().getLayoutDescriptor().getBrickSize(); - //float valueRangeScale = outputIndexer.valueRangeMax - outputIndexer.valueRangeMin; + VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); + float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); //QuantizingValueConverterWithNoValue converter(outputIndexer3D.valueRangeMin, outputIndexer3D.valueRangeMax, valueRangeScale, outputIndexer3D.valueRangeMin, noValue, noValue); int[] numSamples = new int[3]; @@ -101,10 +121,19 @@ public class CreateVDS { } int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + float[] buffer = page.readFloatBuffer(pitch); + + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; - void *buffer = page.getWritableBuffer(pitch); - auto output = static_cast < float *>(buffer); + pageAccessor.getChunkMinMax(i, chunkMin, chunkMax); + float[] floatBuffer = page.readFloatBuffer(pitch); + + //void* buffer = page.getWritableBuffer(pitch); + //auto output = static_cast < float *>(buffer); + + /** for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { @@ -113,7 +142,7 @@ public class CreateVDS { int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localOutIndex); int pos[] = new int[]{ - voxelIndex[0], + voxelIndex[0], voxelIndex[1], voxelIndex[2] }; @@ -122,40 +151,70 @@ public class CreateVDS { output[outputIndexer.localIndexToDataIndex(localOutIndex)] = value; } + */ + + //page.writeFloatBuffer(buffer, pitch); //OpenVDS::CalculateNoise3D(buffer, format, &outputIndexer, frequency, 0.021f, 0.f, true, 345); page.release(); } + /** pageAccessor.commit(); pageAccessor.setMaxPages(0); accessManager.flushUploadQueue(); accessManager.destroyVolumeDataPageAccessor(pageAccessor); + OpenVDS.close(vds); + */ } - static void getScaleOffsetForFormat(float min, float max, boolean novalue, VolumeDataChannelDescriptor.Format format, - float scale, float offset) { +// static float[] getScaleOffsetForFormat(float min, float max, boolean novalue, VolumeDataChannelDescriptor.Format format) { +// float res[] = new float[] {1f, 0f}; +// switch (format) { +// case VolumeDataChannelDescriptor.Format.FORMAT_U8: +// res[0] = 1.f / (255.f - novalue) * (max - min); +// res[1] = min; +// break; +// case VolumeDataChannelDescriptor.Format.FORMAT_U16: +// res[0] = 1.f / (65535.f - novalue) * (max - min); +// res[1] = min; +// break; +// case VolumeDataChannelDescriptor.Format.FORMAT_R32: +// case VolumeDataChannelDescriptor.Format.FORMAT_U32: +// case VolumeDataChannelDescriptor.Format.FORMAT_R64: +// case VolumeDataChannelDescriptor.Format.FORMAT_U64: +// case VolumeDataChannelDescriptor.Format.FORMAT_1BIT: +// case VolumeDataChannelDescriptor.Format.FORMAT_ANY: +// res[0] = 1.0f; +// res[1] = 0.0f; +// } +// return res; +// } + + static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { + float res[] = new float[] {1f, 0f}; + float noValueCmp = useNoValue ? 1f : 0f; switch (format) { - case VolumeDataChannelDescriptor.Format.FORMAT_U8: - scale = 1.f / (255.f - novalue) * (max - min); - offset = min; + case FORMAT_U8: + res[0] = 1.f / (255.f - noValueCmp) * (max - min); + res[1] = min; break; - case VolumeDataChannelDescriptor.Format.FORMAT_U16: - scale = 1.f / (65535.f - novalue) * (max - min); - offset = min; + case FORMAT_U16: + res[0] = 1.f / (65535.f - noValueCmp) * (max - min); + res[1] = min; break; - case VolumeDataChannelDescriptor.Format.FORMAT_R32: - case VolumeDataChannelDescriptor.Format.FORMAT_U32: - case VolumeDataChannelDescriptor.Format.FORMAT_R64: - case VolumeDataChannelDescriptor.Format.FORMAT_U64: - case VolumeDataChannelDescriptor.Format.FORMAT_1BIT: - case VolumeDataChannelDescriptor.Format.FORMAT_ANY: - scale = 1.0f; - offset = 0.0f; + case FORMAT_R32: + case FORMAT_U32: + case FORMAT_R64: + case FORMAT_U64: + case FORMAT_1BIT: + case FORMAT_ANY: + res[0] = 1.0f; + res[1] = 0.0f; } + return res; } -*/ - } + } diff --git a/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java b/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java index 5be7cf2e..1b0da345 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java @@ -18,6 +18,8 @@ package org.opengroup.openvds; import java.nio.*; +import java.util.Arrays; +import java.util.Optional; import static org.opengroup.openvds.VolumeDataChannelDescriptor.Format.*; @@ -26,6 +28,32 @@ import static org.opengroup.openvds.VolumeDataChannelDescriptor.Format.*; */ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { + public enum AccessMode { + ReadOnly(0), + ReadWrite(1), + Create(2); + + private final int code; + + AccessMode(int code) { + this.code = code; + } + + public int getCode() { + return code; + } + + public static AccessMode fromCode(int codeParam) { + Optional first = Arrays + .stream(values()) + .filter(e -> e.getCode() == codeParam) + .findFirst(); + if (!first.isPresent()) + throw new IllegalArgumentException("invalid code"); + return first.get(); + } + } + private static native long cpGetVolumeDataLayout(long handle); private static native int cpGetVDSProduceStatus(long managerHandle, @@ -129,7 +157,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @return the VolumeDataLayout object associated with the VDS or null if * there is no valid VolumeDataLayout. */ - VolumeDataLayout getVolumeDataLayout() { + public VolumeDataLayout getVolumeDataLayout() { return new VolumeDataLayout(cpGetVolumeDataLayout(_handle)); } @@ -146,7 +174,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @return The produce status for the specific DimensionsND/LOD/Channel * combination. */ - VDSProduceStatus getVDSProduceStatus(VolumeDataLayout volumeDataLayout, DimensionsND dimensionsND, int lod, int channel) { + public VDSProduceStatus getVDSProduceStatus(VolumeDataLayout volumeDataLayout, DimensionsND dimensionsND, int lod, int channel) { return VDSProduceStatus.values()[cpGetVDSProduceStatus(_handle, volumeDataLayout.handle(), dimensionsND.ordinal(), lod, channel)]; } @@ -168,7 +196,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @return a VolumeDataPageAccessor object for the VDS associated with the * given VolumeDataLayout object. */ - VolumeDataPageAccessor createVolumeDataPageAccessor(VolumeDataLayout volumeDataLayout, + public VolumeDataPageAccessor createVolumeDataPageAccessor(VolumeDataLayout volumeDataLayout, int dimensionsND, int lod, int channel, int maxPages, int accessMode) { return new VolumeDataPageAccessor(cpCreateVolumeDataPageAccessor( _handle, volumeDataLayout.handle(), @@ -196,7 +224,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @return a VolumeDataPageAccessor object for the VDS associated with the * given VolumeDataLayout object. */ - VolumeDataPageAccessor createVolumeDataPageAccessor(VolumeDataLayout volumeDataLayout, + public VolumeDataPageAccessor createVolumeDataPageAccessor(VolumeDataLayout volumeDataLayout, int dimensionsND, int lod, int channel, int maxPages, int accessMode, int chunkMetadataPageSize) { return new VolumeDataPageAccessor(cpCreateVolumeDataPageAccessor( _handle, volumeDataLayout.handle(), @@ -209,7 +237,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @param volumeDataPageAccessor the VolumeDataPageAccessor object to * destroy. */ - void destroyVolumeDataPageAccessor(VolumeDataPageAccessor volumeDataPageAccessor) { + public void destroyVolumeDataPageAccessor(VolumeDataPageAccessor volumeDataPageAccessor) { cpDestroyVolumeDataPageAccessor(_handle, volumeDataPageAccessor.handle()); } @@ -218,7 +246,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * * @param accessor the VolumeDataAccessor object to destroy. */ - void destroyVolumeDataAccessor(VolumeDataAccessor accessor) { + public void destroyVolumeDataAccessor(VolumeDataAccessor accessor) { cpDestroyVolumeDataAccessor(_handle, accessor.handle()); } @@ -228,7 +256,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @param accessor the VolumeDataAccessor object to clone. * @return a clone of supplied VolumeDataAccessor object */ - VolumeDataAccessor cloneVolumeDataAccessor(VolumeDataAccessor accessor) { + public VolumeDataAccessor cloneVolumeDataAccessor(VolumeDataAccessor accessor) { return new VolumeDataAccessor(cpCloneVolumeDataAccessor(_handle, accessor.handle()), true); } @@ -272,6 +300,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { volumeDataLayout.handle(), dimensionsND.ordinal(), lod, channel, box.getMin(), box.getMax(), FORMAT_R64.getCode()); } + public long requestVolumeSubset(FloatBuffer outBuf, VolumeDataLayout volumeDataLayout, DimensionsND dimensionsND, int lod, int channel, NDBox box) { diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index f1f490fd..066cc91f 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -19,15 +19,28 @@ package org.opengroup.openvds; public class VolumeDataPage extends JniPointer { - private static native void cpDeleteHandle(long handle); + private static native void cpRelease(long handle); + + private static native float[] cpGetFloatBuffer(long handle, int[] pitch); public VolumeDataPage(long handle) { super(handle, true); } + public void release() { + cpRelease(_handle); + } + // Called by JniPointer.release() @Override protected synchronized void deleteHandle() { - cpDeleteHandle(_handle); + cpRelease(_handle); + } + + public float[] readFloatBuffer(int[] pitch) { + if (pitch == null || pitch.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("Wrong pitch array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (pitch == null ? "null" : pitch.length)); + } + return cpGetFloatBuffer(_handle, pitch); } } diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java index a58c8482..92cc20b3 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java @@ -18,16 +18,41 @@ package org.opengroup.openvds; public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { - + private static native long cpGetLayout( long handle ); + private static native long cpGetChunkCount( long handle ); + private static native void cpGetChunkMinMax( long handle, int chunk, int[] chunkMin, int[] chunkMax); + private static native long cpCreatePage( long handle, long chunkIndex); + VolumeDataPageAccessor(long handle) { super(handle); } - VolumeDataLayout getLayout() { - return new VolumeDataLayout( cpGetLayout(_handle) ); - } + public VolumeDataLayout getLayout() { + return new VolumeDataLayout( cpGetLayout(_handle) ); + } + + public long getChunkCount() { + return cpGetChunkCount(_handle); + } + + public void getChunkMinMax(int chunk, int[] chunkMin, int[] chunkMax) { + if (chunk < 0 || chunk >= getChunkCount()) { + throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunk index"); + } + if (chunkMin == null || chunkMin.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunkMin array, expected non null or size 6"); + } + if (chunkMax == null || chunkMax.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunkMax array, expected non null or size 6"); + } + cpGetChunkMinMax(_handle, chunk, chunkMin, chunkMax); + } + + public VolumeDataPage createPage(long chunkIndex) { + return new VolumeDataPage(cpCreatePage(_handle, chunkIndex)); + } /* virtual int GetLOD() const = 0; diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer3D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer3D.java new file mode 100644 index 00000000..5a3f73db --- /dev/null +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer3D.java @@ -0,0 +1,15 @@ +package org.opengroup.openvds; + +public class VolumeIndexer3D extends VolumeIndexerBase { + + private static native long cpCreateVolumeIndexer3D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + + public VolumeIndexer3D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { + super(cpCreateVolumeIndexer3D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 3, true); + } + + public VolumeIndexer3D(long handle) { + super(handle, 3, false); + } + +} diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java new file mode 100644 index 00000000..d5145279 --- /dev/null +++ b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java @@ -0,0 +1,37 @@ +package org.opengroup.openvds; + +public abstract class VolumeIndexerBase extends JniPointer { + + private static native void cpDeleteHandle(long handle, int volumeDimension); + private static native float cpGetValueRangeMin(long handle, int volumeDimension); + private static native float cpGetValueRangeMax(long handle, int volumeDimension); + private static native int cpGetDataBlockNumSamples(long handle, int volumeDimension, int dim); + + private final int dimensionVolume; + + public VolumeIndexerBase(long handle, int dimension, boolean ownHandle) { + super(handle, ownHandle); + this.dimensionVolume = dimension; + } + + protected int getVolumeDimension() { + return dimensionVolume; + } + + @Override + protected void deleteHandle() { + cpDeleteHandle(_handle, dimensionVolume); + } + + public float getValueRangeMin() { + return cpGetValueRangeMin(_handle, dimensionVolume); + } + + public float getValueRangeMax() { + return cpGetValueRangeMax(_handle, dimensionVolume); + } + + public int getDataBlockNumSamples(int dimension) { + return cpGetDataBlockNumSamples(_handle, dimensionVolume, dimension); + } +} diff --git a/java/java/test/org/opengroup/openvds/PageAccessorTest.java b/java/java/test/org/opengroup/openvds/PageAccessorTest.java new file mode 100644 index 00000000..07d789b2 --- /dev/null +++ b/java/java/test/org/opengroup/openvds/PageAccessorTest.java @@ -0,0 +1,139 @@ +package org.opengroup.openvds; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +public class PageAccessorTest { + public String url; + public VolumeDataLayoutDescriptor ld; + public VolumeDataAxisDescriptor[] vda; + public VolumeDataChannelDescriptor[] vdc; + public MetadataReadAccess md; + public MemoryVdsGenerator vds; + private MetadataContainer metadataContainer; + + @BeforeClass + public void init() { + vds = new MemoryVdsGenerator(16, 16, 16, VolumeDataChannelDescriptor.Format.FORMAT_U8); + url = "inmemory://create_test"; + VolumeDataLayout volumeDataLayout = vds.getLayout(); + + int nbChannel = volumeDataLayout.getChannelCount(); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + + for (VolumeDataLayoutDescriptor.LODLevels l : VolumeDataLayoutDescriptor.LODLevels.values()) { + for (int channel = 0; channel < nbChannel; channel++) { + for (DimensionsND dimGroup : DimensionsND.values()) { + VDSProduceStatus vdsProduceStatus = accessManager.getVDSProduceStatus(volumeDataLayout, dimGroup, l.ordinal(), channel); + } + } + } + + vda = new VolumeDataAxisDescriptor[] {volumeDataLayout.getAxisDescriptor(0), + volumeDataLayout.getAxisDescriptor(1), + volumeDataLayout.getAxisDescriptor(2)}; + vdc = new VolumeDataChannelDescriptor[] {volumeDataLayout.getChannelDescriptor(0)}; + + md = volumeDataLayout; + ld = volumeDataLayout.getLayoutDescriptor(); + + metadataContainer = new MetadataContainer(); + metadataContainer.setMetadataInt("categoryInt", "Int", 123); + metadataContainer.setMetadataIntVector2("categoryInt", "IntVector2", new int[] {45, 78}); + metadataContainer.setMetadataIntVector3("categoryInt", "IntVector3", new int[] {45, 78, 72}); + metadataContainer.setMetadataIntVector4("categoryInt", "IntVector4", new int[] {45, 78, 72, 84}); + metadataContainer.setMetadataFloat("categoryFloat", "Float", 123.f); + metadataContainer.setMetadataFloatVector2("categoryFloat", "FloatVector2", new float[] {45.5f, 78.75f}); + metadataContainer.setMetadataFloatVector3("categoryFloat", "FloatVector3", new float[] {45.5f, 78.75f, 72.75f}); + metadataContainer.setMetadataFloatVector4("categoryFloat", "FloatVector4", new float[] {45.5f, 78.75f, 72.75f, 84.1f}); + metadataContainer.setMetadataDouble("categoryDouble", "Double", 123.); + metadataContainer.setMetadataDoubleVector2("categoryDouble", "DoubleVector2", new double[] {45.5, 78.75}); + metadataContainer.setMetadataDoubleVector3("categoryDouble", "DoubleVector3", new double[] {45.5, 78.75, 72.75}); + metadataContainer.setMetadataDoubleVector4("categoryDouble", "DoubleVector4", new double[] {45.5, 78.75, 72.75, 84.1}); + metadataContainer.setMetadataString("categoryString", "String", "Test string"); + //metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); + } + + @Test + public void testVolumeIndexerCreationDeletion() { + try { + VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testVolumeIndexer.vds"); + VdsHandle vds = OpenVDS.create(options, ld, + vda, + vdc, metadataContainer); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + VolumeDataLayout layout = vds.getLayout(); + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + 0, // lod + channel, // channel + 100, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + VolumeDataPage page = pageAccessor.createPage(0); + VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); + + outputIndexer.finalize(); + } + catch (java.io.IOException e) { + System.out.println(e.getMessage()); + fail(); + } + } + + @Test + public void testCreatePageAccessor() { + try { + VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testPageAccessor.vds"); + VdsHandle vds = OpenVDS.create(options, ld, + vda, + vdc, metadataContainer); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + VolumeDataLayout layout = vds.getLayout(); + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + 0, // lod + channel, // channel + 100, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + int chunkCount = (int) pageAccessor.getChunkCount(); + + for (int i = 0; i < chunkCount; i++) { + VolumeDataPage page = pageAccessor.createPage(i); + VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); + + int[] numSamples = new int[3]; + + for (int j = 0; j < 3; j++) { + numSamples[j] = outputIndexer.getDataBlockNumSamples(j); + } + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + + pageAccessor.getChunkMinMax(i, chunkMin, chunkMax); + + float[] floatBuffer = page.readFloatBuffer(pitch); + + System.out.println("Create float buffer succes"); + } + } + catch (java.io.IOException e) { + System.out.println(e.getMessage()); + fail(); + } + } +} -- GitLab From 86c4c7944e23ada9e32b29f2708b7b66a91f326d Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Fri, 9 Apr 2021 11:56:20 +0200 Subject: [PATCH 010/194] VolumeDataPage : read/write float buffer array VolumeIndexND TODO : read/write buffer for other data (byte, double, int, long...) TODO : check consistency (buffer type and format) --- java/CMakeLists.txt | 8 ++ java/cpp/src/VolumeDataPage.cpp | 42 ++++++ java/cpp/src/VolumeDataPageAccessor.cpp | 45 ++++++ java/cpp/src/VolumeIndexer2D.cpp | 61 ++++++++ java/cpp/src/VolumeIndexer4D.cpp | 61 ++++++++ java/cpp/src/VolumeIndexer5D.cpp | 61 ++++++++ java/cpp/src/VolumeIndexer6D.cpp | 61 ++++++++ java/cpp/src/VolumeIndexerBase.cpp | 135 ++++++++++++++++++ java/java/demo/CreateVDS.java | 13 +- .../org/opengroup/openvds/VolumeDataPage.java | 56 ++++++++ .../openvds/VolumeDataPageAccessor.java | 54 +++++++ .../opengroup/openvds/VolumeIndexer2D.java | 15 ++ .../opengroup/openvds/VolumeIndexer4D.java | 15 ++ .../opengroup/openvds/VolumeIndexer5D.java | 15 ++ .../opengroup/openvds/VolumeIndexer6D.java | 15 ++ .../opengroup/openvds/VolumeIndexerBase.java | 18 +++ .../opengroup/openvds/PageAccessorTest.java | 43 ++++-- 17 files changed, 702 insertions(+), 16 deletions(-) create mode 100644 java/cpp/src/VolumeIndexer2D.cpp create mode 100644 java/cpp/src/VolumeIndexer4D.cpp create mode 100644 java/cpp/src/VolumeIndexer5D.cpp create mode 100644 java/cpp/src/VolumeIndexer6D.cpp create mode 100644 java/java/src/org/opengroup/openvds/VolumeIndexer2D.java create mode 100644 java/java/src/org/opengroup/openvds/VolumeIndexer4D.java create mode 100644 java/java/src/org/opengroup/openvds/VolumeIndexer5D.java create mode 100644 java/java/src/org/opengroup/openvds/VolumeIndexer6D.java diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 2062058b..81397d3a 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -51,7 +51,11 @@ set(JAVA_SOURCE_FILES java/src/org/opengroup/openvds/VolumeDataPage.java java/src/org/opengroup/openvds/VolumeDataPageAccessor.java java/src/org/opengroup/openvds/VolumeIndexerBase.java + java/src/org/opengroup/openvds/VolumeIndexer2D.java java/src/org/opengroup/openvds/VolumeIndexer3D.java + java/src/org/opengroup/openvds/VolumeIndexer4D.java + java/src/org/opengroup/openvds/VolumeIndexer5D.java + java/src/org/opengroup/openvds/VolumeIndexer6D.java java/demo/AWSSliceDumpDemo.java java/demo/OpenVdsDemo.java @@ -120,7 +124,11 @@ add_library(openvds-javacpp cpp/src/VolumeDataPage.cpp cpp/src/VolumeDataPageAccessor.cpp cpp/src/VolumeIndexerBase.cpp + cpp/src/VolumeIndexer2D.cpp cpp/src/VolumeIndexer3D.cpp + cpp/src/VolumeIndexer4D.cpp + cpp/src/VolumeIndexer5D.cpp + cpp/src/VolumeIndexer6D.cpp cpp/src/WriteVolumeData.cpp ) diff --git a/java/cpp/src/VolumeDataPage.cpp b/java/cpp/src/VolumeDataPage.cpp index 26a1f3f2..39489d44 100644 --- a/java/cpp/src/VolumeDataPage.cpp +++ b/java/cpp/src/VolumeDataPage.cpp @@ -41,6 +41,24 @@ extern "C" { CATCH_EXCEPTIONS_FOR_JAVA; } + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpGetMinMax + * Signature: (J[I[I)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetMinMax + (JNIEnv * env, jclass, jlong handle, jintArray minArr, jintArray maxArr) + { + try { + int cMin[OpenVDS::Dimensionality_Max]; + int cMax[OpenVDS::Dimensionality_Max]; + GetVolumePage(handle)->GetMinMax(cMin, cMax); + env->SetIntArrayRegion(minArr, 0, OpenVDS::Dimensionality_Max, cMin); + env->SetIntArrayRegion(maxArr, 0, OpenVDS::Dimensionality_Max, cMax); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + /* * Class: org_opengroup_openvds_VolumeDataPage * Method: cpGetWritableFloatBuffer @@ -70,6 +88,30 @@ extern "C" { return NULL; } + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpSetFloatBuffer + * Signature: (J[F[I)[F + */ + JNIEXPORT jfloatArray JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpSetFloatBuffer + (JNIEnv * env, jclass, jlong handle, jfloatArray values, jintArray pitchArr) + { + try { + OpenVDS::VolumeDataPage * page = GetVolumePage(handle); + int pitch[OpenVDS::Dimensionality_Max]; + float* pageBuffer = reinterpret_cast(page->GetWritableBuffer(pitch)); + int valueSize = env->GetArrayLength(values); + jfloat *src = env->GetFloatArrayElements(values, 0); + for (int i = 0 ; i < valueSize ; ++i) { + pageBuffer[i] = static_cast(src[i]); + } + // needed or not? + env->ReleaseFloatArrayElements(values, src, 0); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeDataPageAccessor.cpp b/java/cpp/src/VolumeDataPageAccessor.cpp index d2445196..4953e02c 100644 --- a/java/cpp/src/VolumeDataPageAccessor.cpp +++ b/java/cpp/src/VolumeDataPageAccessor.cpp @@ -76,6 +76,22 @@ extern "C" { return -1; } + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpReadPage + * Signature: (JJ)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpReadPage + (JNIEnv * env, jclass, jlong handle, jlong pageIndex) + { + try { + OpenVDS::VolumeDataPage* volumePage = GetPageAccessor( handle )->ReadPage(pageIndex); + return (jlong) volumePage; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + /* * Class: org_opengroup_openvds_VolumeDataPageAccessor * Method: cpGetChunkMinMax @@ -93,6 +109,35 @@ extern "C" { } CATCH_EXCEPTIONS_FOR_JAVA; } + + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpCommit + * Signature: (J)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpCommit + (JNIEnv * env, jclass, jlong handle) + { + try { + GetPageAccessor( handle )->Commit(); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpSetMaxPage + * Signature: (JI)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpSetMaxPage + (JNIEnv * env, jclass, jlong handle, jint maxPages) + { + try { + GetPageAccessor( handle )->SetMaxPages(maxPages); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeIndexer2D.cpp b/java/cpp/src/VolumeIndexer2D.cpp new file mode 100644 index 00000000..d01edd72 --- /dev/null +++ b/java/cpp/src/VolumeIndexer2D.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +using namespace OpenVDS; + +#ifdef __cplusplus +extern "C" { +#endif + + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { + return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); + } + + inline OpenVDS::VolumeDataPage *GetVolumePage(jlong handle) { + return (OpenVDS::VolumeDataPage *) CheckHandle(handle); + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpCreateVolumeIndexer2D + * Signature: (JIIIJ)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpCreateVolumeIndexer2D + (JNIEnv * env, jclass, jlong vlPageHandle, jint channelIndex, jint lod, jint dimND, jlong layoutHandle) + { + try { + VolumeDataPage* volumeDataPage = GetVolumePage(vlPageHandle); + VolumeDataLayout* layout = GetLayout(layoutHandle); + VolumeIndexer2D* indexer2D = new VolumeIndexer2D(volumeDataPage, channelIndex, lod, (DimensionsND)dimND, layout); + return (jlong)indexer2D; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; + } + +#ifdef __cplusplus +} +#endif + + + diff --git a/java/cpp/src/VolumeIndexer4D.cpp b/java/cpp/src/VolumeIndexer4D.cpp new file mode 100644 index 00000000..f9ffa62f --- /dev/null +++ b/java/cpp/src/VolumeIndexer4D.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +using namespace OpenVDS; + +#ifdef __cplusplus +extern "C" { +#endif + + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { + return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); + } + + inline OpenVDS::VolumeDataPage *GetVolumePage(jlong handle) { + return (OpenVDS::VolumeDataPage *) CheckHandle(handle); + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpCreateVolumeIndexer4D + * Signature: (JIIIJ)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpCreateVolumeIndexer4D + (JNIEnv * env, jclass, jlong vlPageHandle, jint channelIndex, jint lod, jint dimND, jlong layoutHandle) + { + try { + VolumeDataPage* volumeDataPage = GetVolumePage(vlPageHandle); + VolumeDataLayout* layout = GetLayout(layoutHandle); + VolumeIndexer4D* indexer4D = new VolumeIndexer4D(volumeDataPage, channelIndex, lod, (DimensionsND)dimND, layout); + return (jlong)indexer4D; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; + } + +#ifdef __cplusplus +} +#endif + + + diff --git a/java/cpp/src/VolumeIndexer5D.cpp b/java/cpp/src/VolumeIndexer5D.cpp new file mode 100644 index 00000000..34e2ea25 --- /dev/null +++ b/java/cpp/src/VolumeIndexer5D.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +using namespace OpenVDS; + +#ifdef __cplusplus +extern "C" { +#endif + + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { + return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); + } + + inline OpenVDS::VolumeDataPage *GetVolumePage(jlong handle) { + return (OpenVDS::VolumeDataPage *) CheckHandle(handle); + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpCreateVolumeIndexer5D + * Signature: (JIIIJ)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpCreateVolumeIndexer5D + (JNIEnv * env, jclass, jlong vlPageHandle, jint channelIndex, jint lod, jint dimND, jlong layoutHandle) + { + try { + VolumeDataPage* volumeDataPage = GetVolumePage(vlPageHandle); + VolumeDataLayout* layout = GetLayout(layoutHandle); + VolumeIndexer5D* indexer5D = new VolumeIndexer5D(volumeDataPage, channelIndex, lod, (DimensionsND)dimND, layout); + return (jlong)indexer5D; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; + } + +#ifdef __cplusplus +} +#endif + + + diff --git a/java/cpp/src/VolumeIndexer6D.cpp b/java/cpp/src/VolumeIndexer6D.cpp new file mode 100644 index 00000000..d9952144 --- /dev/null +++ b/java/cpp/src/VolumeIndexer6D.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2019 The Open Group + * Copyright 2019 INT, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +using namespace OpenVDS; + +#ifdef __cplusplus +extern "C" { +#endif + + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { + return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); + } + + inline OpenVDS::VolumeDataPage *GetVolumePage(jlong handle) { + return (OpenVDS::VolumeDataPage *) CheckHandle(handle); + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpCreateVolumeIndexer6D + * Signature: (JIIIJ)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpCreateVolumeIndexer6D + (JNIEnv * env, jclass, jlong vlPageHandle, jint channelIndex, jint lod, jint dimND, jlong layoutHandle) + { + try { + VolumeDataPage* volumeDataPage = GetVolumePage(vlPageHandle); + VolumeDataLayout* layout = GetLayout(layoutHandle); + VolumeIndexer6D* indexer6D = new VolumeIndexer6D(volumeDataPage, channelIndex, lod, (DimensionsND)dimND, layout); + return (jlong)indexer6D; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; + } + +#ifdef __cplusplus +} +#endif + + + diff --git a/java/cpp/src/VolumeIndexerBase.cpp b/java/cpp/src/VolumeIndexerBase.cpp index 4bdf2f9a..13ebee60 100644 --- a/java/cpp/src/VolumeIndexerBase.cpp +++ b/java/cpp/src/VolumeIndexerBase.cpp @@ -155,6 +155,141 @@ extern "C" { return -1; } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpLocalIndexToVoxelIndex + * Signature: (JI[I)[I + */ + JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) + { + try { + std::vector vecLI = JArrayToVector(env, localIndex); + std::vector vecRes(volumeDimension, 0); + int arrayRes[volumeDimension]; + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + for (int i = 0; i < volumeDimension; ++i) { + vec2[i] = vecLI[i]; + } + IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToVoxelIndex(vec2); + for (int i = 0; i < volumeDimension; ++i) { + vecRes[i] = res2[i]; + } + break; + } + case 3: { + IntVector3 vec3; + for (int i = 0; i < volumeDimension; ++i) { + vec3[i] = vecLI[i]; + } + IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToVoxelIndex(vec3); + for (int i = 0; i < volumeDimension; ++i) { + vecRes[i] = res3[i]; + } + break; + } + case 4:{ + IntVector4 vec4; + for (int i = 0; i < volumeDimension; ++i) { + vec4[i] = vecLI[i]; + } + IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToVoxelIndex(vec4); + for (int i = 0; i < volumeDimension; ++i) { + vecRes[i] = res4[i]; + } + break; + } + case 5: { + IntVector<5> vec5; + for (int i = 0; i < volumeDimension; ++i) { + vec5[i] = vecLI[i]; + } + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToVoxelIndex(vec5); + for (int i = 0; i < volumeDimension; ++i) { + vecRes[i] = res5[i]; + } + break; + } + case 6: { + IntVector<6> vec6; + for (int i = 0; i < volumeDimension; ++i) { + vec6[i] = vecLI[i]; + } + IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToVoxelIndex(vec6); + for (int i = 0; i < volumeDimension; ++i) { + vecRes[i] = res6[i]; + } + break; + } + } + for (int i = 0; i < volumeDimension; ++i) { + arrayRes[i] = vecRes[i]; + } + return NewJIntArray(env, arrayRes, volumeDimension); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpLocalIndexToDataIndex + * Signature: (JI[I)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) + { + try { + switch (volumeDimension) { + case 2: { + std::vector vecLI = JArrayToVector(env, localIndex); + IntVector2 vec2; + for (int i = 0; i < volumeDimension; ++i) { + vec2[i] = vecLI[i]; + } + return GetVolumeIndexer2D(handle)->LocalIndexToDataIndex(vec2); + } + case 3: { + std::vector vecLI = JArrayToVector(env, localIndex); + IntVector3 vec3; + for (int i = 0; i < volumeDimension; ++i) { + vec3[i] = vecLI[i]; + } + return GetVolumeIndexer3D(handle)->LocalIndexToDataIndex(vec3); + } + case 4: { + std::vector vecLI = JArrayToVector(env, localIndex); + IntVector4 vec4; + for (int i = 0; i < volumeDimension; ++i) { + vec4[i] = vecLI[i]; + } + return GetVolumeIndexer4D(handle)->LocalIndexToDataIndex(vec4); + } + case 5: { + std::vector vecLI = JArrayToVector(env, localIndex); + IntVector<5> vec5; + for (int i = 0; i < volumeDimension; ++i) { + vec5[i] = vecLI[i]; + } + return GetVolumeIndexer5D(handle)->LocalIndexToDataIndex(vec5); + } + case 6: { + std::vector vecLI = JArrayToVector(env, localIndex); + IntVector<6> vec6; + for (int i = 0; i < volumeDimension; ++i) { + vec6[i] = vecLI[i]; + } + return GetVolumeIndexer6D(handle)->LocalIndexToDataIndex(vec6); + } + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + #ifdef __cplusplus } #endif diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index 38c94ff2..327986fb 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -128,12 +128,11 @@ public class CreateVDS { pageAccessor.getChunkMinMax(i, chunkMin, chunkMax); - float[] floatBuffer = page.readFloatBuffer(pitch); + float[] output = page.readFloatBuffer(pitch); //void* buffer = page.getWritableBuffer(pitch); //auto output = static_cast < float *>(buffer); - /** for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { @@ -151,23 +150,21 @@ public class CreateVDS { output[outputIndexer.localIndexToDataIndex(localOutIndex)] = value; } - */ - //page.writeFloatBuffer(buffer, pitch); + + page.writeFloatBuffer(buffer, pitch); //OpenVDS::CalculateNoise3D(buffer, format, &outputIndexer, frequency, 0.021f, 0.f, true, 345); page.release(); } - /** + pageAccessor.commit(); pageAccessor.setMaxPages(0); accessManager.flushUploadQueue(); accessManager.destroyVolumeDataPageAccessor(pageAccessor); - - OpenVDS.close(vds); - */ + vds.close(); // equivalent to OpenVDS.close(vds); ? } // static float[] getScaleOffsetForFormat(float min, float max, boolean novalue, VolumeDataChannelDescriptor.Format format) { diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index 066cc91f..981576cb 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -21,12 +21,23 @@ public class VolumeDataPage extends JniPointer { private static native void cpRelease(long handle); + private static native void cpGetMinMax(long handle, int[] min, int[] max); + private static native float[] cpGetFloatBuffer(long handle, int[] pitch); + private static native float[] cpSetFloatBuffer(long handle, float[] buffer,int[] pitch); + public VolumeDataPage(long handle) { super(handle, true); } + public VolumeDataPage(long handle, boolean ownHandle) { + super(handle, ownHandle); + } + + /** + * Release page + */ public void release() { cpRelease(_handle); } @@ -37,10 +48,55 @@ public class VolumeDataPage extends JniPointer { cpRelease(_handle); } + /** + * Get min max extent, and set results in array parameters + * @param min arrays that will receive min values + * @param max arrays that will receive max values + */ + public void getMinMax(int[] min, int[] max) { + if (min == null || min.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("Wrong min array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (min == null ? "null" : min.length)); + } + if (max == null || max.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("Wrong max array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (max == null ? "null" : max.length)); + } + cpGetMinMax(_handle, min, max); + } + + /** + * Read float array of page + * @param pitch will receive pitch values for this page + * @return the float array of page data + */ public float[] readFloatBuffer(int[] pitch) { if (pitch == null || pitch.length != VolumeDataLayout.Dimensionality_Max) { throw new IllegalArgumentException("Wrong pitch array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (pitch == null ? "null" : pitch.length)); } return cpGetFloatBuffer(_handle, pitch); } + + /** + * Set float array int page + * @param pitch pitch values + */ + public void writeFloatBuffer(float[] buffer, int[] pitch) { + if (pitch == null || pitch.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("Wrong pitch array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (pitch == null ? "null" : pitch.length)); + } + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + getMinMax(chunkMin, chunkMax); + int elementCount = getElementCount(chunkMin, chunkMax); + if (buffer == null || buffer.length != elementCount) { + throw new IllegalArgumentException("Wrong buffer size, expected " + elementCount + ", got " + (buffer == null ? "null" : buffer.length)); + } + cpSetFloatBuffer(_handle, buffer, pitch); + } + + private int getElementCount(int[] min, int[] max) { + int chunkSizeI = max[2] - min[2]; + int chunkSizeX = max[1] - min[1]; + int chunkSizeZ = max[0] - min[0]; + return chunkSizeI * chunkSizeX * chunkSizeZ; + } } diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java index 92cc20b3..3ec36eee 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java @@ -23,20 +23,37 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { private static native long cpGetChunkCount( long handle ); private static native void cpGetChunkMinMax( long handle, int chunk, int[] chunkMin, int[] chunkMax); private static native long cpCreatePage( long handle, long chunkIndex); + private static native long cpReadPage( long handle, long chunkIndex); + private static native void cpCommit(long handle); + private static native void cpSetMaxPage(long handle, int maxPage); VolumeDataPageAccessor(long handle) { super(handle); } + /** + * Get volume layout + * @return + */ public VolumeDataLayout getLayout() { return new VolumeDataLayout( cpGetLayout(_handle) ); } + /** + * @return the chunk count + */ public long getChunkCount() { return cpGetChunkCount(_handle); } + /** + * Get chunk dimension + * @param chunk chunk index + * @param chunkMin array that will receive min values + * @param chunkMax array that will receive max values + * @throws IllegalArgumentException if chunk min and max array don't have the correct size, or if chunk index is incorrect + */ public void getChunkMinMax(int chunk, int[] chunkMin, int[] chunkMax) { if (chunk < 0 || chunk >= getChunkCount()) { throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunk index"); @@ -50,10 +67,47 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { cpGetChunkMinMax(_handle, chunk, chunkMin, chunkMax); } + /** + * Create page for given chunk index + * @param chunkIndex + * @return A VolumeDataPage + * @throws IllegalArgumentException if chunkIndex is incorrect + */ public VolumeDataPage createPage(long chunkIndex) { + if (chunkIndex < 0 || chunkIndex >= getChunkCount()) { + throw new IllegalArgumentException("VolumeDataPageAccessor::createPage : wrong chunk index"); + } return new VolumeDataPage(cpCreatePage(_handle, chunkIndex)); } + /** + * Reads page for given chunk index + * @param chunkIndex + * @return A VolumeDataPage + * @throws IllegalArgumentException if chunkIndex is incorrect + */ + public VolumeDataPage readPage(long chunkIndex) { + if (chunkIndex < 0 || chunkIndex >= getChunkCount()) { + throw new IllegalArgumentException("VolumeDataPageAccessor::readPage : wrong chunk index"); + } + return new VolumeDataPage(cpReadPage(_handle, chunkIndex)); + } + + /** + * Commit modification + */ + public void commit() { + cpCommit(_handle); + } + + /** + * Set maximum number of pages + * @param maxPages page count + */ + public void setMaxPages(int maxPages) { + cpSetMaxPage(_handle, maxPages); + } + /* virtual int GetLOD() const = 0; virtual int GetChannelIndex() const = 0; diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer2D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer2D.java new file mode 100644 index 00000000..4eb98057 --- /dev/null +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer2D.java @@ -0,0 +1,15 @@ +package org.opengroup.openvds; + +public class VolumeIndexer2D extends VolumeIndexerBase { + + private static native long cpCreateVolumeIndexer2D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + + public VolumeIndexer2D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { + super(cpCreateVolumeIndexer2D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 2, true); + } + + public VolumeIndexer2D(long handle) { + super(handle, 2, false); + } + +} diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer4D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer4D.java new file mode 100644 index 00000000..9e0ca002 --- /dev/null +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer4D.java @@ -0,0 +1,15 @@ +package org.opengroup.openvds; + +public class VolumeIndexer4D extends VolumeIndexerBase { + + private static native long cpCreateVolumeIndexer4D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + + public VolumeIndexer4D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { + super(cpCreateVolumeIndexer4D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 4, true); + } + + public VolumeIndexer4D(long handle) { + super(handle, 4, false); + } + +} diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer5D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer5D.java new file mode 100644 index 00000000..1d2ddedf --- /dev/null +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer5D.java @@ -0,0 +1,15 @@ +package org.opengroup.openvds; + +public class VolumeIndexer5D extends VolumeIndexerBase { + + private static native long cpCreateVolumeIndexer5D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + + public VolumeIndexer5D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { + super(cpCreateVolumeIndexer5D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 5, true); + } + + public VolumeIndexer5D(long handle) { + super(handle, 5, false); + } + +} diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer6D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer6D.java new file mode 100644 index 00000000..6ae7d8f0 --- /dev/null +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer6D.java @@ -0,0 +1,15 @@ +package org.opengroup.openvds; + +public class VolumeIndexer6D extends VolumeIndexerBase { + + private static native long cpCreateVolumeIndexer6D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + + public VolumeIndexer6D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { + super(cpCreateVolumeIndexer6D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 6, true); + } + + public VolumeIndexer6D(long handle) { + super(handle, 6, false); + } + +} diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java index d5145279..5076b90c 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java @@ -6,6 +6,8 @@ public abstract class VolumeIndexerBase extends JniPointer { private static native float cpGetValueRangeMin(long handle, int volumeDimension); private static native float cpGetValueRangeMax(long handle, int volumeDimension); private static native int cpGetDataBlockNumSamples(long handle, int volumeDimension, int dim); + private static native int[] cpLocalIndexToVoxelIndex(long handle, int volumeDimension, int[] localIndex); + private static native int cpLocalIndexToDataIndex(long handle, int volumeDimension, int[] localIndex); private final int dimensionVolume; @@ -34,4 +36,20 @@ public abstract class VolumeIndexerBase extends JniPointer { public int getDataBlockNumSamples(int dimension) { return cpGetDataBlockNumSamples(_handle, dimensionVolume, dimension); } + + public int[] localIndexToVoxelIndex(int[] localIndex) { + checkLocalIndexArgument(localIndex); + return cpLocalIndexToVoxelIndex(_handle, dimensionVolume, localIndex); + } + + public int localIndexToDataIndex(int[] localIndex) { + checkLocalIndexArgument(localIndex); + return cpLocalIndexToDataIndex(_handle, dimensionVolume, localIndex); + } + + private void checkLocalIndexArgument(int[] localIndex) { + if (localIndex == null || localIndex.length != dimensionVolume) { + throw new IllegalArgumentException("Local index size must match indexer dimension. Expected " + dimensionVolume + ", got " + (localIndex != null ? localIndex.length : "null")); + } + } } diff --git a/java/java/test/org/opengroup/openvds/PageAccessorTest.java b/java/java/test/org/opengroup/openvds/PageAccessorTest.java index 07d789b2..fd37af25 100644 --- a/java/java/test/org/opengroup/openvds/PageAccessorTest.java +++ b/java/java/test/org/opengroup/openvds/PageAccessorTest.java @@ -17,7 +17,7 @@ public class PageAccessorTest { @BeforeClass public void init() { - vds = new MemoryVdsGenerator(16, 16, 16, VolumeDataChannelDescriptor.Format.FORMAT_U8); + vds = new MemoryVdsGenerator(16, 16, 16, VolumeDataChannelDescriptor.Format.FORMAT_R32); url = "inmemory://create_test"; VolumeDataLayout volumeDataLayout = vds.getLayout(); @@ -61,14 +61,14 @@ public class PageAccessorTest { public void testVolumeIndexerCreationDeletion() { try { VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testVolumeIndexer.vds"); - VdsHandle vds = OpenVDS.create(options, ld, + VdsHandle vdsTest = OpenVDS.create(options, ld, vda, vdc, metadataContainer); - VolumeDataAccessManager accessManager = vds.getAccessManager(); + VolumeDataAccessManager accessManager = vdsTest.getAccessManager(); //ASSERT_TRUE(accessManager); int channel = 0; - VolumeDataLayout layout = vds.getLayout(); + VolumeDataLayout layout = vdsTest.getLayout(); VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( layout, // layout DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND @@ -79,8 +79,9 @@ public class PageAccessorTest { VolumeDataPage page = pageAccessor.createPage(0); VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); - outputIndexer.finalize(); + + vdsTest.close(); } catch (java.io.IOException e) { System.out.println(e.getMessage()); @@ -92,14 +93,14 @@ public class PageAccessorTest { public void testCreatePageAccessor() { try { VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testPageAccessor.vds"); - VdsHandle vds = OpenVDS.create(options, ld, + VdsHandle vdsPageAccessor = OpenVDS.create(options, ld, vda, vdc, metadataContainer); - VolumeDataAccessManager accessManager = vds.getAccessManager(); + VolumeDataAccessManager accessManager = vdsPageAccessor.getAccessManager(); //ASSERT_TRUE(accessManager); int channel = 0; - VolumeDataLayout layout = vds.getLayout(); + VolumeDataLayout layout = vdsPageAccessor.getLayout(); VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( layout, // layout DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND @@ -128,8 +129,34 @@ public class PageAccessorTest { float[] floatBuffer = page.readFloatBuffer(pitch); + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + int[] localOutIndex = new int[]{iDim0, iDim1, iDim2}; + + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localOutIndex); + + int pos[] = new int[]{ + voxelIndex[0], + voxelIndex[1], + voxelIndex[2] + }; + + float value = pos[0]; + int dataIndex = outputIndexer.localIndexToDataIndex(localOutIndex); + floatBuffer[dataIndex] = value; + } + page.writeFloatBuffer(floatBuffer, pitch); + page.release(); System.out.println("Create float buffer succes"); } + + pageAccessor.commit(); + pageAccessor.setMaxPages(0); + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + + vdsPageAccessor.close(); } catch (java.io.IOException e) { System.out.println(e.getMessage()); -- GitLab From 7f28d29f64a9c9638b91a0ae56bfde4682bc8b0f Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Fri, 9 Apr 2021 18:29:28 +0200 Subject: [PATCH 011/194] VolumeDataPage : read/write float buffer array TODO : check volumeIndexer Conversion, add methods to the Indexer TODO : check consistency (buffer type and format) --- java/cpp/src/VolumeDataPage.cpp | 123 +++++++++++++++++- java/cpp/src/VolumeDataPageAccessor.cpp | 19 +++ java/java/demo/CreateVDS.java | 9 +- .../openvds/VolumeDataLayoutDescriptor.java | 24 ++-- .../org/opengroup/openvds/VolumeDataPage.java | 114 +++++++++++++--- .../openvds/VolumeDataPageAccessor.java | 36 +++-- .../opengroup/openvds/PageAccessorTest.java | 61 ++++++--- tools/ScratchVDSFileCreate/VDSFileCreate.cpp | 12 +- 8 files changed, 337 insertions(+), 61 deletions(-) diff --git a/java/cpp/src/VolumeDataPage.cpp b/java/cpp/src/VolumeDataPage.cpp index 39489d44..9c9ea43f 100644 --- a/java/cpp/src/VolumeDataPage.cpp +++ b/java/cpp/src/VolumeDataPage.cpp @@ -59,6 +59,74 @@ extern "C" { CATCH_EXCEPTIONS_FOR_JAVA; } + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpGetMinMaxExcludingMargin + * Signature: (J[I[I)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetMinMaxExcludingMargin + (JNIEnv * env, jclass, jlong handle, jintArray minArr, jintArray maxArr) + { + try { + int cMin[OpenVDS::Dimensionality_Max]; + int cMax[OpenVDS::Dimensionality_Max]; + GetVolumePage(handle)->GetMinMaxExcludingMargin(cMin, cMax); + env->SetIntArrayRegion(minArr, 0, OpenVDS::Dimensionality_Max, cMin); + env->SetIntArrayRegion(maxArr, 0, OpenVDS::Dimensionality_Max, cMax); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpGetByteBuffer + * Signature: (J[I)[B + */ + JNIEXPORT jbyteArray JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetByteBuffer + (JNIEnv * env, jclass, jlong handle, jintArray pitchParam) + { + try { + int pitch[OpenVDS::Dimensionality_Max]; + int cMin[OpenVDS::Dimensionality_Max]; + int cMax[OpenVDS::Dimensionality_Max]; + GetVolumePage(handle)->GetMinMax(cMin, cMax); + + int chunk_size_i = cMax[2] - cMin[2]; + int chunk_size_x = cMax[1] - cMin[1]; + int chunk_size_z = cMax[0] - cMin[0]; + + char* readData = reinterpret_cast(GetVolumePage(handle)->GetWritableBuffer(pitch)); + env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); + + int nbElem = chunk_size_i * chunk_size_x * chunk_size_z; + return NewJByteArray(env, readData, nbElem); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpSetByteBuffer + * Signature: (J[B)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpSetByteBuffer + (JNIEnv * env, jclass, jlong handle, jbyteArray values) + { + try { + OpenVDS::VolumeDataPage * page = GetVolumePage(handle); + int pitch[OpenVDS::Dimensionality_Max]; + unsigned char* pageBuffer = reinterpret_cast(page->GetWritableBuffer(pitch)); + int valueSize = env->GetArrayLength(values); + jbyte *src = env->GetByteArrayElements(values, 0); + for (int i = 0 ; i < valueSize ; ++i) { + pageBuffer[i] = static_cast(src[i]); + } + // needed or not? + env->ReleaseByteArrayElements(values, src, 0); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + /* * Class: org_opengroup_openvds_VolumeDataPage * Method: cpGetWritableFloatBuffer @@ -68,7 +136,6 @@ extern "C" { (JNIEnv * env, jclass, jlong handle, jintArray pitchParam) { try { - std::vector vecPitch = JArrayToVector(env, pitchParam); int pitch[OpenVDS::Dimensionality_Max]; int cMin[OpenVDS::Dimensionality_Max]; int cMax[OpenVDS::Dimensionality_Max]; @@ -93,8 +160,8 @@ extern "C" { * Method: cpSetFloatBuffer * Signature: (J[F[I)[F */ - JNIEXPORT jfloatArray JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpSetFloatBuffer - (JNIEnv * env, jclass, jlong handle, jfloatArray values, jintArray pitchArr) + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpSetFloatBuffer + (JNIEnv * env, jclass, jlong handle, jfloatArray values) { try { OpenVDS::VolumeDataPage * page = GetVolumePage(handle); @@ -109,9 +176,59 @@ extern "C" { env->ReleaseFloatArrayElements(values, src, 0); } CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpGetDoubleBuffer + * Signature: (J[I)[D + */ + JNIEXPORT jdoubleArray JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetDoubleBuffer + (JNIEnv * env, jclass, jlong handle, jintArray pitchParam) + { + try { + int pitch[OpenVDS::Dimensionality_Max]; + int cMin[OpenVDS::Dimensionality_Max]; + int cMax[OpenVDS::Dimensionality_Max]; + GetVolumePage(handle)->GetMinMax(cMin, cMax); + + int chunk_size_i = cMax[2] - cMin[2]; + int chunk_size_x = cMax[1] - cMin[1]; + int chunk_size_z = cMax[0] - cMin[0]; + + double* readData = reinterpret_cast(GetVolumePage(handle)->GetWritableBuffer(pitch)); + env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); + + int nbElem = chunk_size_i * chunk_size_x * chunk_size_z; + return NewJDoubleArray(env, readData, nbElem); + } + CATCH_EXCEPTIONS_FOR_JAVA; return NULL; } + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpSetDoubleBuffer + * Signature: (J[D)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpSetDoubleBuffer + (JNIEnv * env, jclass, jlong handle, jdoubleArray values) + { + try { + OpenVDS::VolumeDataPage * page = GetVolumePage(handle); + int pitch[OpenVDS::Dimensionality_Max]; + double* pageBuffer = reinterpret_cast(page->GetWritableBuffer(pitch)); + int valueSize = env->GetArrayLength(values); + jdouble *src = env->GetDoubleArrayElements(values, 0); + for (int i = 0 ; i < valueSize ; ++i) { + pageBuffer[i] = static_cast(src[i]); + } + // needed or not? + env->ReleaseDoubleArrayElements(values, src, 0); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeDataPageAccessor.cpp b/java/cpp/src/VolumeDataPageAccessor.cpp index 4953e02c..feca4cb1 100644 --- a/java/cpp/src/VolumeDataPageAccessor.cpp +++ b/java/cpp/src/VolumeDataPageAccessor.cpp @@ -110,6 +110,25 @@ extern "C" { CATCH_EXCEPTIONS_FOR_JAVA; } + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpGetChunkMinMaxExcludingMargin + * Signature: (JI[I[I)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetChunkMinMaxExcludingMargin + (JNIEnv * env, jclass, jlong handle, jint chunk, jintArray chunkMin, jintArray chunkMax) + { + try { + int cMin[OpenVDS::Dimensionality_Max]; + int cMax[OpenVDS::Dimensionality_Max]; + GetPageAccessor( handle )->GetChunkMinMaxExcludingMargin(chunk, cMin, cMax); + env->SetIntArrayRegion(chunkMin, 0, OpenVDS::Dimensionality_Max, cMin); + env->SetIntArrayRegion(chunkMax, 0, OpenVDS::Dimensionality_Max, cMax); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* * Class: org_opengroup_openvds_VolumeDataPageAccessor * Method: cpCommit diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index 327986fb..f1f88ae9 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -121,12 +121,17 @@ public class CreateVDS { } int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; - float[] buffer = page.readFloatBuffer(pitch); + //float[] buffer = page.readFloatBuffer(pitch); int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; pageAccessor.getChunkMinMax(i, chunkMin, chunkMax); + int chunkSizeI = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + int nbElem = chunkSizeI * chunkSizeX * chunkSizeZ; + float[] buffer = new float[nbElem]; float[] output = page.readFloatBuffer(pitch); @@ -152,7 +157,7 @@ public class CreateVDS { } - page.writeFloatBuffer(buffer, pitch); + page.writeFloatBuffer(buffer); //OpenVDS::CalculateNoise3D(buffer, format, &outputIndexer, frequency, 0.021f, 0.f, true, 345); page.release(); diff --git a/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java b/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java index 5e2eaaa3..0ea98c28 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java @@ -26,19 +26,21 @@ import java.util.Optional; public class VolumeDataLayoutDescriptor { public enum BrickSize { - BRICK_SIZE_32(5), - BRICK_SIZE_64(6), - BRICK_SIZE_128(7), - BRICK_SIZE_256(8), - BRICK_SIZE_512(9), - BRICK_SIZE_1024(10), - BRICK_SIZE_2048(11), - BRICK_SIZE_4096(12); + BRICK_SIZE_32(5, 32), + BRICK_SIZE_64(6, 64), + BRICK_SIZE_128(7, 128), + BRICK_SIZE_256(8, 256), + BRICK_SIZE_512(9, 512), + BRICK_SIZE_1024(10, 1024), + BRICK_SIZE_2048(11, 2048), + BRICK_SIZE_4096(12, 4096); private final int code; + private final int dimension; - BrickSize(int code) { + BrickSize(int code, int dim) { this.code = code; + this.dimension = dim; } public static BrickSize fromCode(int code) { @@ -54,6 +56,10 @@ public class VolumeDataLayoutDescriptor { public int getCode() { return code; } + + public int getDimension() { + return dimension; + } } public enum LODLevels { diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index 981576cb..da305e40 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -23,9 +23,19 @@ public class VolumeDataPage extends JniPointer { private static native void cpGetMinMax(long handle, int[] min, int[] max); + private static native void cpGetMinMaxExcludingMargin(long handle, int[] min, int[] max); + + private static native byte[] cpGetByteBuffer(long handle, int[] pitch); + + private static native void cpSetByteBuffer(long handle, byte[] buffer); + private static native float[] cpGetFloatBuffer(long handle, int[] pitch); - private static native float[] cpSetFloatBuffer(long handle, float[] buffer,int[] pitch); + private static native void cpSetFloatBuffer(long handle, float[] buffer); + + private static native double[] cpGetDoubleBuffer(long handle, int[] pitch); + + private static native void cpSetDoubleBuffer(long handle, double[] buffer); public VolumeDataPage(long handle) { super(handle, true); @@ -45,7 +55,7 @@ public class VolumeDataPage extends JniPointer { // Called by JniPointer.release() @Override protected synchronized void deleteHandle() { - cpRelease(_handle); + //cpRelease(_handle); } /** @@ -54,43 +64,111 @@ public class VolumeDataPage extends JniPointer { * @param max arrays that will receive max values */ public void getMinMax(int[] min, int[] max) { - if (min == null || min.length != VolumeDataLayout.Dimensionality_Max) { - throw new IllegalArgumentException("Wrong min array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (min == null ? "null" : min.length)); - } - if (max == null || max.length != VolumeDataLayout.Dimensionality_Max) { - throw new IllegalArgumentException("Wrong max array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (max == null ? "null" : max.length)); - } + checkDimParamArray(min, "Wrong min array parameter size, expected "); + checkDimParamArray(max, "Wrong max array parameter size, expected "); cpGetMinMax(_handle, min, max); } + /** + * Get min max extent, and set results in array parameters + * @param min arrays that will receive min values + * @param max arrays that will receive max values + */ + public void getMinMaxExcludingMargin(int[] min, int[] max) { + checkDimParamArray(min, "Wrong min array parameter size, expected "); + checkDimParamArray(max, "Wrong max array parameter size, expected "); + cpGetMinMaxExcludingMargin(_handle, min, max); + } + + /** + * Read byte array of page + * @param pitch will receive pitch values for this page + * @return the float array of page data + */ + public byte[] readByteBuffer(int[] pitch) { + checkDimParamArray(pitch, "Wrong pitch array parameter size, expected "); + return cpGetByteBuffer(_handle, pitch); + } + + /** + * Set byte array int page + * @param buffer values to set. Size must match page sample size + */ + public void writeByteBuffer(byte[] buffer) { + checkBufferSize(buffer); + cpSetByteBuffer(_handle, buffer); + } + /** * Read float array of page * @param pitch will receive pitch values for this page * @return the float array of page data */ public float[] readFloatBuffer(int[] pitch) { - if (pitch == null || pitch.length != VolumeDataLayout.Dimensionality_Max) { - throw new IllegalArgumentException("Wrong pitch array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (pitch == null ? "null" : pitch.length)); - } + checkDimParamArray(pitch, "Wrong pitch array parameter size, expected "); return cpGetFloatBuffer(_handle, pitch); } /** * Set float array int page - * @param pitch pitch values + * @param buffer values to set. Size must match page sample size */ - public void writeFloatBuffer(float[] buffer, int[] pitch) { - if (pitch == null || pitch.length != VolumeDataLayout.Dimensionality_Max) { - throw new IllegalArgumentException("Wrong pitch array parameter size, expected " + VolumeDataLayout.Dimensionality_Max + ", got " + (pitch == null ? "null" : pitch.length)); - } + public void writeFloatBuffer(float[] buffer) { + checkBufferSize(buffer); + cpSetFloatBuffer(_handle, buffer); + } + + /** + * Read double array of page + * @param pitch will receive pitch values for this page + * @return the double array of page data + */ + public double[] readDoubleBuffer(int[] pitch) { + checkDimParamArray(pitch, "Wrong pitch array parameter size, expected "); + return cpGetDoubleBuffer(_handle, pitch); + } + + /** + * Set double array int page + * @param buffer values to set. Size must match page sample size + */ + public void writeDoubleBuffer(double[] buffer) { + checkBufferSize(buffer); + cpSetDoubleBuffer(_handle, buffer); + } + + private int getElementCount() { int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; getMinMax(chunkMin, chunkMax); - int elementCount = getElementCount(chunkMin, chunkMax); + return getElementCount(chunkMin, chunkMax); + } + + private void checkBufferSize(byte[] buffer) { + int elementCount = getElementCount(); if (buffer == null || buffer.length != elementCount) { throw new IllegalArgumentException("Wrong buffer size, expected " + elementCount + ", got " + (buffer == null ? "null" : buffer.length)); } - cpSetFloatBuffer(_handle, buffer, pitch); + } + + private void checkBufferSize(float[] buffer) { + int elementCount = getElementCount(); + if (buffer == null || buffer.length != elementCount) { + throw new IllegalArgumentException("Wrong buffer size, expected " + elementCount + ", got " + (buffer == null ? "null" : buffer.length)); + } + } + + private void checkBufferSize(double[] buffer) { + int elementCount = getElementCount(); + if (buffer == null || buffer.length != elementCount) { + throw new IllegalArgumentException("Wrong buffer size, expected " + elementCount + ", got " + (buffer == null ? "null" : buffer.length)); + } + } + + private void checkDimParamArray(int[] pitch, String s) { + if (pitch == null || pitch.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException(s + VolumeDataLayout.Dimensionality_Max + ", got " + (pitch == null ? "null" : pitch.length)); + } } private int getElementCount(int[] min, int[] max) { diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java index 3ec36eee..9e885715 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java @@ -22,6 +22,7 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { private static native long cpGetLayout( long handle ); private static native long cpGetChunkCount( long handle ); private static native void cpGetChunkMinMax( long handle, int chunk, int[] chunkMin, int[] chunkMax); + private static native void cpGetChunkMinMaxExcludingMargin( long handle, int chunk, int[] chunkMin, int[] chunkMax); private static native long cpCreatePage( long handle, long chunkIndex); private static native long cpReadPage( long handle, long chunkIndex); private static native void cpCommit(long handle); @@ -55,18 +56,24 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { * @throws IllegalArgumentException if chunk min and max array don't have the correct size, or if chunk index is incorrect */ public void getChunkMinMax(int chunk, int[] chunkMin, int[] chunkMax) { - if (chunk < 0 || chunk >= getChunkCount()) { - throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunk index"); - } - if (chunkMin == null || chunkMin.length != VolumeDataLayout.Dimensionality_Max) { - throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunkMin array, expected non null or size 6"); - } - if (chunkMax == null || chunkMax.length != VolumeDataLayout.Dimensionality_Max) { - throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunkMax array, expected non null or size 6"); - } + checkChunkAndArraySize(chunk, chunkMin, chunkMax); cpGetChunkMinMax(_handle, chunk, chunkMin, chunkMax); } + + + /** + * Get chunk dimension (without margin) + * @param chunk chunk index + * @param chunkMin array that will receive min values + * @param chunkMax array that will receive max values + * @throws IllegalArgumentException if chunk min and max array don't have the correct size, or if chunk index is incorrect + */ + public void getChunkMinMaxExcludingMargin(int chunk, int[] chunkMin, int[] chunkMax) { + checkChunkAndArraySize(chunk, chunkMin, chunkMax); + cpGetChunkMinMaxExcludingMargin(_handle, chunk, chunkMin, chunkMax); + } + /** * Create page for given chunk index * @param chunkIndex @@ -108,6 +115,17 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { cpSetMaxPage(_handle, maxPages); } + private void checkChunkAndArraySize(int chunk, int[] chunkMin, int[] chunkMax) { + if (chunk < 0 || chunk >= getChunkCount()) { + throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunk index"); + } + if (chunkMin == null || chunkMin.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunkMin array, expected non null or size 6"); + } + if (chunkMax == null || chunkMax.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunkMax array, expected non null or size 6"); + } + } /* virtual int GetLOD() const = 0; virtual int GetChannelIndex() const = 0; diff --git a/java/java/test/org/opengroup/openvds/PageAccessorTest.java b/java/java/test/org/opengroup/openvds/PageAccessorTest.java index fd37af25..616de482 100644 --- a/java/java/test/org/opengroup/openvds/PageAccessorTest.java +++ b/java/java/test/org/opengroup/openvds/PageAccessorTest.java @@ -17,7 +17,7 @@ public class PageAccessorTest { @BeforeClass public void init() { - vds = new MemoryVdsGenerator(16, 16, 16, VolumeDataChannelDescriptor.Format.FORMAT_R32); + vds = new MemoryVdsGenerator(100, 100, 100, VolumeDataChannelDescriptor.Format.FORMAT_R32); url = "inmemory://create_test"; VolumeDataLayout volumeDataLayout = vds.getLayout(); @@ -32,7 +32,8 @@ public class PageAccessorTest { } } - vda = new VolumeDataAxisDescriptor[] {volumeDataLayout.getAxisDescriptor(0), + vda = new VolumeDataAxisDescriptor[] { + volumeDataLayout.getAxisDescriptor(0), volumeDataLayout.getAxisDescriptor(1), volumeDataLayout.getAxisDescriptor(2)}; vdc = new VolumeDataChannelDescriptor[] {volumeDataLayout.getChannelDescriptor(0)}; @@ -92,7 +93,7 @@ public class PageAccessorTest { @Test public void testCreatePageAccessor() { try { - VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testPageAccessor.vds"); + VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testPageAccessorFloat100_100_100.vds"); VdsHandle vdsPageAccessor = OpenVDS.create(options, ld, vda, vdc, metadataContainer); @@ -110,28 +111,45 @@ public class PageAccessorTest { VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode int chunkCount = (int) pageAccessor.getChunkCount(); - + System.out.println("Nombre de chunks : " + chunkCount); for (int i = 0; i < chunkCount; i++) { VolumeDataPage page = pageAccessor.createPage(i); + System.out.println("Page created : " + i); VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); + System.out.println("\tOutput indexer created : " + i); int[] numSamples = new int[3]; - for (int j = 0; j < 3; j++) { numSamples[j] = outputIndexer.getDataBlockNumSamples(j); } + System.out.println("\tChunk dim (" + i + ") : I " + numSamples[0] + " - X " + numSamples[1] + " - Z " + numSamples[2]); int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; - pageAccessor.getChunkMinMax(i, chunkMin, chunkMax); - - float[] floatBuffer = page.readFloatBuffer(pitch); + page.getMinMax(chunkMin, chunkMax); + int chunkSizeI = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + int nbElem = chunkSizeI * chunkSizeX * chunkSizeZ; + float[] buffer = new float[nbElem]; + System.out.println("\tGot min max : " + i); + System.out.println("\tChunk coords (" + i + ") : I " + chunkMin[2] + "/" + chunkMax[2] + " - X " + chunkMin[1] + "/" + chunkMax[1] + " - Z " + chunkMin[0] + "/" + chunkMax[0]); + + //float[] buffer = page.readFloatBuffer(pitch); + //double[] buffer = page.readDoubleBuffer(pitch); + //byte[] buffer = page.readByteBuffer(pitch); + + for (int idx = 0 ; idx < buffer.length ; ++idx) { + buffer[idx] = (float) (idx % 256); + } - for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) - for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) - for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + int smp = 0; + for (int iDim2 = 0; iDim2 < chunkSizeI; iDim2++) { + System.out.print("."); + for (int iDim1 = 0; iDim1 < chunkSizeX; iDim1++) { + for (int iDim0 = 0; iDim0 < chunkSizeZ; iDim0++) { int[] localOutIndex = new int[]{iDim0, iDim1, iDim2}; int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localOutIndex); @@ -143,12 +161,25 @@ public class PageAccessorTest { }; float value = pos[0]; - int dataIndex = outputIndexer.localIndexToDataIndex(localOutIndex); - floatBuffer[dataIndex] = value; + //double value = pos[0]; + //byte value = (byte) (pos[0] % Byte.MAX_VALUE); + int dataIndex = outputIndexer.localIndexToDataIndex(pos); + if (dataIndex < buffer.length) { + buffer[dataIndex] = value; + ++smp; + } } - page.writeFloatBuffer(floatBuffer, pitch); + } + } + System.out.println(""); + System.out.println("\t" + smp + " samples will be written"); + System.out.println("\tWill write buffer " + i); + page.writeFloatBuffer(buffer); + System.out.println("\tDone write buffer " + i); + //page.writeDoubleBuffer(buffer); + //page.writeByteBuffer(buffer); page.release(); - System.out.println("Create float buffer succes"); + System.out.println("Page writed : " + i); } pageAccessor.commit(); diff --git a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp index 5ea808d6..b9d15546 100644 --- a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp +++ b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp @@ -100,9 +100,9 @@ getScaleOffsetForFormat(float min, float max, bool novalue, OpenVDS::VolumeDataC int main(int argc, char *argv[]) { - int32_t samplesX = 1000; - int32_t samplesY = 1000; - int32_t samplesZ = 1000; + int32_t samplesX = 100; + int32_t samplesY = 100; + int32_t samplesZ = 50; OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_64; @@ -134,7 +134,7 @@ main(int argc, char *argv[]) { OpenVDS::VolumeDataChannelDescriptor::Default, 0.f, intScale, intOffset); //OpenVDS::InMemoryOpenOptions options; - OpenVDS::VDSFileOpenOptions options("/mnt/dataDD/tmp/create.vds"); + OpenVDS::VDSFileOpenOptions options("/tmp/createCPP.vds"); OpenVDS::Error error; OpenVDS::MetadataContainer metadataContainer; @@ -170,7 +170,7 @@ main(int argc, char *argv[]) { //ASSERT_TRUE(pageAccessor); int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); - + std::cout << "Chunk Count = " << chunkCount << "\n"; //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); for (int i = 0; i < chunkCount; i++) { @@ -188,6 +188,8 @@ main(int argc, char *argv[]) { numSamples[j] = outputIndexer.GetDataBlockNumSamples(j); } + std::cout << "\tChunk dim = " << numSamples[0] << " " << numSamples[1] << " " << numSamples[2] << "\n"; + int pitch[OpenVDS::Dimensionality_Max]; void *buffer = page->GetWritableBuffer(pitch); -- GitLab From fe32cbf3275bdc1489452461e579ea10d15d2ad3 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Tue, 13 Apr 2021 12:13:10 +0200 Subject: [PATCH 012/194] VolumeDataPage : read/write float buffer array TODO : check volumeIndexer Conversion, add methods to the Indexer TODO : volumetry (crash on big cube) --- java/cpp/src/VolumeDataPage.cpp | 16 +++---- java/java/demo/CreateVDS.java | 48 ++++++++++++------- .../openvds/VolumeDataLayoutDescriptor.java | 2 +- .../org/opengroup/openvds/VolumeDataPage.java | 5 +- tools/ScratchVDSFileCreate/VDSFileCreate.cpp | 6 +-- 5 files changed, 42 insertions(+), 35 deletions(-) diff --git a/java/cpp/src/VolumeDataPage.cpp b/java/cpp/src/VolumeDataPage.cpp index 9c9ea43f..be3deb7f 100644 --- a/java/cpp/src/VolumeDataPage.cpp +++ b/java/cpp/src/VolumeDataPage.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -115,12 +116,11 @@ extern "C" { try { OpenVDS::VolumeDataPage * page = GetVolumePage(handle); int pitch[OpenVDS::Dimensionality_Max]; + std::cout << "\tGet writable buffer in JNI SetByteBuffer" << std::endl; unsigned char* pageBuffer = reinterpret_cast(page->GetWritableBuffer(pitch)); int valueSize = env->GetArrayLength(values); jbyte *src = env->GetByteArrayElements(values, 0); - for (int i = 0 ; i < valueSize ; ++i) { - pageBuffer[i] = static_cast(src[i]); - } + std::memcpy(pageBuffer, src, valueSize * sizeof (char)); // needed or not? env->ReleaseByteArrayElements(values, src, 0); } @@ -145,7 +145,7 @@ extern "C" { int chunk_size_x = cMax[1] - cMin[1]; int chunk_size_z = cMax[0] - cMin[0]; - float* readData = reinterpret_cast(GetVolumePage(handle)->GetWritableBuffer(pitch)); + float* readData = static_cast(GetVolumePage(handle)->GetWritableBuffer(pitch)); env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); int nbElem = chunk_size_i * chunk_size_x * chunk_size_z; @@ -169,9 +169,7 @@ extern "C" { float* pageBuffer = reinterpret_cast(page->GetWritableBuffer(pitch)); int valueSize = env->GetArrayLength(values); jfloat *src = env->GetFloatArrayElements(values, 0); - for (int i = 0 ; i < valueSize ; ++i) { - pageBuffer[i] = static_cast(src[i]); - } + std::memcpy(pageBuffer, src, valueSize * sizeof (float)); // needed or not? env->ReleaseFloatArrayElements(values, src, 0); } @@ -220,9 +218,7 @@ extern "C" { double* pageBuffer = reinterpret_cast(page->GetWritableBuffer(pitch)); int valueSize = env->GetArrayLength(values); jdouble *src = env->GetDoubleArrayElements(values, 0); - for (int i = 0 ; i < valueSize ; ++i) { - pageBuffer[i] = static_cast(src[i]); - } + std::memcpy(pageBuffer, src, valueSize * sizeof (double)); // needed or not? env->ReleaseDoubleArrayElements(values, src, 0); } diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index f1f88ae9..73008565 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -1,7 +1,9 @@ import org.opengroup.openvds.*; +import sun.awt.X11.XSystemTrayPeer; import java.util.ArrayList; import java.util.List; +import java.util.Random; public class CreateVDS { @@ -16,9 +18,9 @@ public class CreateVDS { static void process(String[] args) throws Exception { - int samplesX = 1000; - int samplesY = 1000; - int samplesZ = 1000; + int samplesX = 200; // time + int samplesY = 300; // XL + int samplesZ = 400; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_64; @@ -32,8 +34,8 @@ public class CreateVDS { List axisDescriptors = new ArrayList<>(); axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "ms", 0.0f,4.f)); - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1932.f, 2536.f)); - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 9985.f,10369.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",0f, 0f + samplesY - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 0f, 0f + samplesZ - 1f)); List channelDescriptors = new ArrayList<>(); @@ -60,7 +62,7 @@ public class CreateVDS { //OpenVDS::InMemoryOpenOptions options; - VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/create.vds"); + VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/createMain.vds"); VdsError error; MetadataContainer metadataContainer = new MetadataContainer(); @@ -96,17 +98,19 @@ public class CreateVDS { DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND 0, // lod channel, // channel - 100, // max pages + 1000, // max pages VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode //ASSERT_TRUE(pageAccessor); int chunkCount = (int) pageAccessor.getChunkCount(); - + System.out.println("Nombre de chunks " + chunkCount); //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); + Random r = new Random(); for (int i = 0; i < chunkCount; i++) { VolumeDataPage page = pageAccessor.createPage(i); + System.out.print("Page " + i + " created "); VolumeDataLayoutDescriptor.BrickSize brickSize1 = pageAccessor.getLayout().getLayoutDescriptor().getBrickSize(); VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); @@ -126,15 +130,21 @@ public class CreateVDS { int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; - pageAccessor.getChunkMinMax(i, chunkMin, chunkMax); + page.getMinMax(chunkMin, chunkMax); + System.out.println("Coords page : " + chunkMin[2] + "/" + chunkMax[2] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[0] + "/" + chunkMax[0]); int chunkSizeI = chunkMax[2] - chunkMin[2]; int chunkSizeX = chunkMax[1] - chunkMin[1]; int chunkSizeZ = chunkMax[0] - chunkMin[0]; int nbElem = chunkSizeI * chunkSizeX * chunkSizeZ; - float[] buffer = new float[nbElem]; + float[] bufferOut = new float[nbElem]; float[] output = page.readFloatBuffer(pitch); + //float[] output = new float[0]; + for (int o = 0 ; o < bufferOut.length ; ++o) { + float randomValue = 0.2468f * (float)r.nextDouble(); + bufferOut[o] = -0.1234f + randomValue; + } //void* buffer = page.getWritableBuffer(pitch); //auto output = static_cast < float *>(buffer); @@ -145,7 +155,7 @@ public class CreateVDS { int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localOutIndex); - int pos[] = new int[]{ + int pos[] = new int[] { voxelIndex[0], voxelIndex[1], voxelIndex[2] @@ -153,23 +163,27 @@ public class CreateVDS { float value = pos[0]; - output[outputIndexer.localIndexToDataIndex(localOutIndex)] = value; + int i1 = outputIndexer.localIndexToDataIndex(localOutIndex); + if (i1 >= 0 && i1 < output.length) + output[i1] = value; } - - page.writeFloatBuffer(buffer); + //System.out.println("Write buffer in page " + i); + page.writeFloatBuffer(bufferOut); //OpenVDS::CalculateNoise3D(buffer, format, &outputIndexer, frequency, 0.021f, 0.f, true, 345); - page.release(); + page.pageRelease(); } - + System.out.println("Everything created"); pageAccessor.commit(); - pageAccessor.setMaxPages(0); + System.out.println("Commit done"); + //pageAccessor.setMaxPages(0); accessManager.flushUploadQueue(); accessManager.destroyVolumeDataPageAccessor(pageAccessor); vds.close(); // equivalent to OpenVDS.close(vds); ? + System.out.println("VDS closed"); } // static float[] getScaleOffsetForFormat(float min, float max, boolean novalue, VolumeDataChannelDescriptor.Format format) { diff --git a/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java b/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java index 0ea98c28..80108704 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataLayoutDescriptor.java @@ -93,7 +93,7 @@ public class VolumeDataLayoutDescriptor { int positiveMargin, int brickSize2DMultiplier, LODLevels lodLevels, boolean isCreate2DLODs, boolean isForceFullResolutionDimension, int fullResolutionDimension) { - _values[BRICK_SIZE] = brickSize.ordinal(); + _values[BRICK_SIZE] = brickSize.getCode(); _values[NEGATIVE_MARGIN] = negativeMargin; _values[POSITIVE_MARGIN] = positiveMargin; _values[BRICK_SIZE_2D_MULTIPLIER] = brickSize2DMultiplier; diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index da305e40..7b840d31 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -45,10 +45,7 @@ public class VolumeDataPage extends JniPointer { super(handle, ownHandle); } - /** - * Release page - */ - public void release() { + public void pageRelease() { cpRelease(_handle); } diff --git a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp index b9d15546..670ee1e2 100644 --- a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp +++ b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp @@ -100,9 +100,9 @@ getScaleOffsetForFormat(float min, float max, bool novalue, OpenVDS::VolumeDataC int main(int argc, char *argv[]) { - int32_t samplesX = 100; - int32_t samplesY = 100; - int32_t samplesZ = 50; + int32_t samplesX = 500; + int32_t samplesY = 500; + int32_t samplesZ = 250; OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_64; -- GitLab From 16a3d061ff61fa4748bdf5e241b4af28485c4638 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Tue, 13 Apr 2021 16:53:29 +0200 Subject: [PATCH 013/194] VolumeDataPage : read/write float buffer array Conversion method added in VolumeIndexerBase TODO : clean unit test TODO : check axis range TODO : main with local/voxel/chunk conversion --- java/cpp/src/VolumeIndexerBase.cpp | 509 ++++++++++++++++-- java/java/demo/CreateVDS.java | 6 +- .../opengroup/openvds/VolumeIndexerBase.java | 106 ++++ tools/ScratchVDSFileCreate/VDSFileCreate.cpp | 10 +- 4 files changed, 570 insertions(+), 61 deletions(-) diff --git a/java/cpp/src/VolumeIndexerBase.cpp b/java/cpp/src/VolumeIndexerBase.cpp index 13ebee60..83349ba5 100644 --- a/java/cpp/src/VolumeIndexerBase.cpp +++ b/java/cpp/src/VolumeIndexerBase.cpp @@ -47,6 +47,66 @@ extern "C" { return (VolumeIndexer6D*)CheckHandle( handle ); } + inline void fillIntVector2(IntVector2 iv, std::vector source) { + for (int i = 0; i < 2 ; ++i) { + iv[i] = source[i]; + } + } + + inline void fillIntVector3(IntVector3 iv, std::vector source) { + for (int i = 0; i < 3 ; ++i) { + iv[i] = source[i]; + } + } + + inline void fillIntVector4(IntVector4 iv, std::vector source) { + for (int i = 0; i < 4 ; ++i) { + iv[i] = source[i]; + } + } + + inline void fillIntVector5(IntVector<5> iv, std::vector source) { + for (int i = 0; i < 5 ; ++i) { + iv[i] = source[i]; + } + } + + inline void fillIntVector6(IntVector<6> iv, std::vector source) { + for (int i = 0; i < 6 ; ++i) { + iv[i] = source[i]; + } + } + + inline void fillIntArrayFromVector2(int array[], IntVector2 vec2) { + for (int i = 0 ; i < 2 ; ++i) { + array[i] = vec2[i]; + } + } + + inline void fillIntArrayFromVector3(int array[], IntVector3 vec3) { + for (int i = 0 ; i < 3 ; ++i) { + array[i] = vec3[i]; + } + } + + inline void fillIntArrayFromVector4(int array[], IntVector4 vec4) { + for (int i = 0 ; i < 4 ; ++i) { + array[i] = vec4[i]; + } + } + + inline void fillIntArrayFromVector5(int array[], IntVector<5> vec5) { + for (int i = 0 ; i < 5 ; ++i) { + array[i] = vec5[i]; + } + } + + inline void fillIntArrayFromVector6(int array[], IntVector<6> vec6) { + for (int i = 0 ; i < 6 ; ++i) { + array[i] = vec6[i]; + } + } + /* * Class: org_opengroup_openvds_VolumeIndexerBase * Method: cpDeleteHandle @@ -155,6 +215,32 @@ extern "C" { return -1; } + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpGetLocalChunkNumSamples + * Signature: (JII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpGetLocalChunkNumSamples + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jint dim) + { + try { + switch (volumeDimension) { + case 2: + return GetVolumeIndexer2D(handle)->GetLocalChunkNumSamples(dim); + case 3: + return GetVolumeIndexer3D(handle)->GetLocalChunkNumSamples(dim); + case 4: + return GetVolumeIndexer4D(handle)->GetLocalChunkNumSamples(dim); + case 5: + return GetVolumeIndexer5D(handle)->GetLocalChunkNumSamples(dim); + case 6: + return GetVolumeIndexer6D(handle)->GetLocalChunkNumSamples(dim); + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + /* * Class: org_opengroup_openvds_VolumeIndexerBase @@ -166,67 +252,313 @@ extern "C" { { try { std::vector vecLI = JArrayToVector(env, localIndex); - std::vector vecRes(volumeDimension, 0); int arrayRes[volumeDimension]; switch (volumeDimension) { case 2: { IntVector2 vec2; - for (int i = 0; i < volumeDimension; ++i) { - vec2[i] = vecLI[i]; - } + fillIntVector2(vec2, vecLI); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToVoxelIndex(vec2); - for (int i = 0; i < volumeDimension; ++i) { - vecRes[i] = res2[i]; - } + fillIntArrayFromVector2(arrayRes, res2); break; } case 3: { IntVector3 vec3; - for (int i = 0; i < volumeDimension; ++i) { - vec3[i] = vecLI[i]; - } + fillIntVector3(vec3, vecLI); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToVoxelIndex(vec3); - for (int i = 0; i < volumeDimension; ++i) { - vecRes[i] = res3[i]; - } + fillIntArrayFromVector3(arrayRes, res3); break; } case 4:{ IntVector4 vec4; - for (int i = 0; i < volumeDimension; ++i) { - vec4[i] = vecLI[i]; - } + fillIntVector4(vec4, vecLI); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToVoxelIndex(vec4); - for (int i = 0; i < volumeDimension; ++i) { - vecRes[i] = res4[i]; - } + fillIntArrayFromVector4(arrayRes, res4); break; } case 5: { IntVector<5> vec5; - for (int i = 0; i < volumeDimension; ++i) { - vec5[i] = vecLI[i]; - } + fillIntVector5(vec5, vecLI); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToVoxelIndex(vec5); - for (int i = 0; i < volumeDimension; ++i) { - vecRes[i] = res5[i]; - } + fillIntArrayFromVector5(arrayRes, res5); break; } case 6: { IntVector<6> vec6; - for (int i = 0; i < volumeDimension; ++i) { - vec6[i] = vecLI[i]; - } + fillIntVector6(vec6, vecLI); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToVoxelIndex(vec6); - for (int i = 0; i < volumeDimension; ++i) { - vecRes[i] = res6[i]; - } + fillIntArrayFromVector6(arrayRes, res6); break; } } - for (int i = 0; i < volumeDimension; ++i) { - arrayRes[i] = vecRes[i]; + return NewJIntArray(env, arrayRes, volumeDimension); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpLocalIndexToLocalChunkIndex + * Signature: (JI[I)[I + */ + JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) + { + try { + std::vector vecLI = JArrayToVector(env, localIndex); + int arrayRes[volumeDimension]; + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(vec2, vecLI); + IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToLocalChunkIndex(vec2); + fillIntArrayFromVector2(arrayRes, res2); + break; + } + case 3: { + IntVector3 vec3; + fillIntVector3(vec3, vecLI); + IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToLocalChunkIndex(vec3); + fillIntArrayFromVector3(arrayRes, res3); + break; + } + case 4: { + IntVector4 vec4; + fillIntVector4(vec4, vecLI); + IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToLocalChunkIndex(vec4); + fillIntArrayFromVector4(arrayRes, res4); + break; + } + case 5: { + IntVector<5> vec5; + fillIntVector5(vec5, vecLI); + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToLocalChunkIndex(vec5); + fillIntArrayFromVector5(arrayRes, res5); + break; + } + case 6: { + IntVector<6> vec6; + fillIntVector6(vec6, vecLI); + IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToLocalChunkIndex(vec6); + fillIntArrayFromVector6(arrayRes, res6); + break; + } + } + return NewJIntArray(env, arrayRes, volumeDimension); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpVoxelIndexToLocalIndex + * Signature: (JI[I)[I + */ + JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) + { + try { + std::vector vecVI = JArrayToVector(env, voxelIndex); + int arrayRes[volumeDimension]; + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(vec2, vecVI); + IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalIndex(vec2); + fillIntArrayFromVector2(arrayRes, res2); + break; + } + case 3: { + IntVector3 vec3; + fillIntVector3(vec3, vecVI); + IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalIndex(vec3); + fillIntArrayFromVector3(arrayRes, res3); + break; + } + case 4: { + IntVector4 vec4; + fillIntVector4(vec4, vecVI); + IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalIndex(vec4); + fillIntArrayFromVector4(arrayRes, res4); + break; + } + case 5: { + IntVector<5> vec5; + fillIntVector5(vec5, vecVI); + IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalIndex(vec5); + fillIntArrayFromVector5(arrayRes, res5); + break; + } + case 6: { + IntVector<6> vec6; + fillIntVector6(vec6, vecVI); + IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalIndex(vec6); + fillIntArrayFromVector6(arrayRes, res6); + break; + } + } + return NewJIntArray(env, arrayRes, volumeDimension); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpVoxelIndexToLocalChunkIndex + * Signature: (JI[I)[I + */ + JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) + { + try { + std::vector vecVI = JArrayToVector(env, voxelIndex); + int arrayRes[volumeDimension]; + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(vec2, vecVI); + IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalChunkIndex(vec2); + fillIntArrayFromVector2(arrayRes, res2); + break; + } + case 3: { + IntVector3 vec3; + fillIntVector3(vec3, vecVI); + IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalChunkIndex(vec3); + fillIntArrayFromVector3(arrayRes, res3); + break; + } + case 4: { + IntVector4 vec4; + fillIntVector4(vec4, vecVI); + IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalChunkIndex(vec4); + fillIntArrayFromVector4(arrayRes, res4); + break; + } + case 5: { + IntVector<5> vec5; + fillIntVector5(vec5, vecVI); + IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalChunkIndex(vec5); + fillIntArrayFromVector5(arrayRes, res5); + break; + } + case 6: { + IntVector<6> vec6; + fillIntVector6(vec6, vecVI); + IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalChunkIndex(vec6); + fillIntArrayFromVector6(arrayRes, res6); + break; + } + } + return NewJIntArray(env, arrayRes, volumeDimension); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpLocalChunkIndexToLocalIndex + * Signature: (JI[I)[I + */ + JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) + { + try { + std::vector vecLCI = JArrayToVector(env, localChunkIndex); + int arrayRes[volumeDimension]; + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(vec2, vecLCI); + IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToLocalIndex(vec2); + fillIntArrayFromVector2(arrayRes, res2); + break; + } + case 3: { + IntVector3 vec3; + fillIntVector3(vec3, vecLCI); + IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToLocalIndex(vec3); + fillIntArrayFromVector3(arrayRes, res3); + break; + } + case 4: { + IntVector4 vec4; + fillIntVector4(vec4, vecLCI); + IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToLocalIndex(vec4); + fillIntArrayFromVector4(arrayRes, res4); + break; + } + case 5: { + IntVector<5> vec5; + fillIntVector5(vec5, vecLCI); + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToLocalIndex(vec5); + fillIntArrayFromVector5(arrayRes, res5); + break; + } + case 6: { + IntVector<6> vec6; + fillIntVector6(vec6, vecLCI); + IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToLocalIndex(vec6); + fillIntArrayFromVector6(arrayRes, res6); + break; + } + } + return NewJIntArray(env, arrayRes, volumeDimension); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpLocalChunkIndexToVoxelIndex + * Signature: (JI[I)[I + */ + JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) + { + try { + std::vector vecLCI = JArrayToVector(env, localChunkIndex); + int arrayRes[volumeDimension]; + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(vec2, vecLCI); + IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToVoxelIndex(vec2); + fillIntArrayFromVector2(arrayRes, res2); + break; + } + case 3: { + IntVector3 vec3; + fillIntVector3(vec3, vecLCI); + IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToVoxelIndex(vec3); + fillIntArrayFromVector3(arrayRes, res3); + break; + } + case 4: { + IntVector4 vec4; + fillIntVector4(vec4, vecLCI); + IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToVoxelIndex(vec4); + fillIntArrayFromVector4(arrayRes, res4); + break; + } + case 5: { + IntVector<5> vec5; + fillIntVector5(vec5, vecLCI); + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToVoxelIndex(vec5); + fillIntArrayFromVector5(arrayRes, res5); + break; + } + case 6: { + IntVector<6> vec6; + fillIntVector6(vec6, vecLCI); + IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToVoxelIndex(vec6); + fillIntArrayFromVector6(arrayRes, res6); + break; + } } return NewJIntArray(env, arrayRes, volumeDimension); } @@ -243,45 +575,31 @@ extern "C" { (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) { try { + std::vector vecLI = JArrayToVector(env, localIndex); switch (volumeDimension) { case 2: { - std::vector vecLI = JArrayToVector(env, localIndex); IntVector2 vec2; - for (int i = 0; i < volumeDimension; ++i) { - vec2[i] = vecLI[i]; - } + fillIntVector2(vec2, vecLI); return GetVolumeIndexer2D(handle)->LocalIndexToDataIndex(vec2); } case 3: { - std::vector vecLI = JArrayToVector(env, localIndex); IntVector3 vec3; - for (int i = 0; i < volumeDimension; ++i) { - vec3[i] = vecLI[i]; - } + fillIntVector3(vec3, vecLI); return GetVolumeIndexer3D(handle)->LocalIndexToDataIndex(vec3); } case 4: { - std::vector vecLI = JArrayToVector(env, localIndex); IntVector4 vec4; - for (int i = 0; i < volumeDimension; ++i) { - vec4[i] = vecLI[i]; - } + fillIntVector4(vec4, vecLI); return GetVolumeIndexer4D(handle)->LocalIndexToDataIndex(vec4); } case 5: { - std::vector vecLI = JArrayToVector(env, localIndex); IntVector<5> vec5; - for (int i = 0; i < volumeDimension; ++i) { - vec5[i] = vecLI[i]; - } + fillIntVector5(vec5, vecLI); return GetVolumeIndexer5D(handle)->LocalIndexToDataIndex(vec5); } case 6: { - std::vector vecLI = JArrayToVector(env, localIndex); IntVector<6> vec6; - for (int i = 0; i < volumeDimension; ++i) { - vec6[i] = vecLI[i]; - } + fillIntVector6(vec6, vecLI); return GetVolumeIndexer6D(handle)->LocalIndexToDataIndex(vec6); } } @@ -290,6 +608,91 @@ extern "C" { return -1; } + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpVoxelIndexToDataIndex + * Signature: (JI[I)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) + { + try { + std::vector vecLI = JArrayToVector(env, voxelIndex); + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(vec2, vecLI); + return GetVolumeIndexer2D(handle)->VoxelIndexToDataIndex(vec2); + } + case 3: { + IntVector3 vec3; + fillIntVector3(vec3, vecLI); + return GetVolumeIndexer3D(handle)->VoxelIndexToDataIndex(vec3); + } + case 4: { + IntVector4 vec4; + fillIntVector4(vec4, vecLI); + return GetVolumeIndexer4D(handle)->VoxelIndexToDataIndex(vec4); + } + case 5: { + IntVector<5> vec5; + fillIntVector5(vec5, vecLI); + return GetVolumeIndexer5D(handle)->VoxelIndexToDataIndex(vec5); + } + case 6: { + IntVector<6> vec6; + fillIntVector6(vec6, vecLI); + return GetVolumeIndexer6D(handle)->VoxelIndexToDataIndex(vec6); + } + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpLocalChunkIndexToDataIndex + * Signature: (JI[I)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) + { + try { + std::vector vecLI = JArrayToVector(env, localChunkIndex); + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(vec2, vecLI); + return GetVolumeIndexer2D(handle)->LocalIndexToDataIndex(vec2); + } + case 3: { + IntVector3 vec3; + fillIntVector3(vec3, vecLI); + return GetVolumeIndexer3D(handle)->LocalIndexToDataIndex(vec3); + } + case 4: { + IntVector4 vec4; + fillIntVector4(vec4, vecLI); + return GetVolumeIndexer4D(handle)->LocalIndexToDataIndex(vec4); + } + case 5: { + IntVector<5> vec5; + fillIntVector5(vec5, vecLI); + return GetVolumeIndexer5D(handle)->LocalIndexToDataIndex(vec5); + } + case 6: { + IntVector<6> vec6; + fillIntVector6(vec6, vecLI); + return GetVolumeIndexer6D(handle)->LocalIndexToDataIndex(vec6); + } + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + #ifdef __cplusplus } #endif diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index 73008565..db66bcd4 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -18,9 +18,9 @@ public class CreateVDS { static void process(String[] args) throws Exception { - int samplesX = 200; // time - int samplesY = 300; // XL - int samplesZ = 400; // IL + int samplesX = 400; // time + int samplesY = 600; // XL + int samplesZ = 600; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_64; diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java index 5076b90c..9ffbb3cd 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java @@ -5,9 +5,22 @@ public abstract class VolumeIndexerBase extends JniPointer { private static native void cpDeleteHandle(long handle, int volumeDimension); private static native float cpGetValueRangeMin(long handle, int volumeDimension); private static native float cpGetValueRangeMax(long handle, int volumeDimension); + private static native int cpGetDataBlockNumSamples(long handle, int volumeDimension, int dim); + private static native int cpGetLocalChunkNumSamples(long handle, int volumeDimension, int dim); + private static native int[] cpLocalIndexToVoxelIndex(long handle, int volumeDimension, int[] localIndex); + private static native int[] cpLocalIndexToLocalChunkIndex(long handle, int volumeDimension, int[] localIndex); + + private static native int[] cpVoxelIndexToLocalIndex(long handle, int volumeDimension, int[] voxelIndex); + private static native int[] cpVoxelIndexToLocalChunkIndex(long handle, int volumeDimension, int[] voxelIndex); + + private static native int[] cpLocalChunkIndexToLocalIndex(long handle, int volumeDimension, int[] voxelIndex); + private static native int[] cpLocalChunkIndexToVoxelIndex(long handle, int volumeDimension, int[] voxelIndex); + private static native int cpLocalIndexToDataIndex(long handle, int volumeDimension, int[] localIndex); + private static native int cpVoxelIndexToDataIndex(long handle, int volumeDimension, int[] voxelIndex); + private static native int cpLocalChunkIndexToDataIndex(long handle, int volumeDimension, int[] localChunkIndex); private final int dimensionVolume; @@ -33,20 +46,113 @@ public abstract class VolumeIndexerBase extends JniPointer { return cpGetValueRangeMax(_handle, dimensionVolume); } + /** + * Gets the number of samples for a dimension in the DataBlock + * @param dimension the volume dimension + * @return the number of samples in the dimension + */ public int getDataBlockNumSamples(int dimension) { return cpGetDataBlockNumSamples(_handle, dimensionVolume, dimension); } + /** + * Get the number of samples for a dimension in the volume + * @param dimension the volume dimension + * @return the number of samples in the dimension + */ + public int getLocalChunkNumSamples(int dimension) { return cpGetLocalChunkNumSamples(_handle, dimensionVolume, dimension); }; + + /** + * Converts a local index to a voxel index + * @param localIndex the local index to convert + * @return the voxel index + */ public int[] localIndexToVoxelIndex(int[] localIndex) { checkLocalIndexArgument(localIndex); return cpLocalIndexToVoxelIndex(_handle, dimensionVolume, localIndex); } + /** + * Converts a local index to a local chunk index + * @param localIndex the local index to convert + * @return the local chunk index + */ + public int[] localIndexToLocalChunkIndex(int[] localIndex) { + checkLocalIndexArgument(localIndex); + return cpLocalIndexToLocalChunkIndex(_handle, dimensionVolume, localIndex); + } + + /** + * Converts a voxel index to a local index + * @param voxelIndex the voxel index to convert + * @return the local index + */ + public int[] voxelIndexToLocalIndex(int[] voxelIndex) { + checkLocalIndexArgument(voxelIndex); + return cpVoxelIndexToLocalIndex(_handle, dimensionVolume, voxelIndex); + } + + /** + * Converts a voxel index to a local chunk index + * @param voxelIndex the voxel index to convert + * @return the local index + */ + public int[] voxelIndexToLocalChunkIndex(int[] voxelIndex) { + checkLocalIndexArgument(voxelIndex); + return cpVoxelIndexToLocalChunkIndex(_handle, dimensionVolume, voxelIndex); + } + + /** + * Converts a local chunk index to a local index + * @param localChunkIndex the local chunk index to convert + * @return the local index + */ + public int[] localChunkIndexToLocalIndex(int[] localChunkIndex) { + checkLocalIndexArgument(localChunkIndex); + return cpLocalChunkIndexToLocalIndex(_handle, dimensionVolume, localChunkIndex); + } + + /** + * Converts a local chunk index to a voxel index + * @param localChunkIndex + * @return the local voxel index + */ + public int[] localChunkIndexToVoxelIndex(int[] localChunkIndex) { + checkLocalIndexArgument(localChunkIndex); + return cpLocalChunkIndexToVoxelIndex(_handle, dimensionVolume, localChunkIndex); + } + + /** + * Converts a local index to a data index + * @param localIndex the local index to convert + * @return the buffer offset (position) for the local index + */ public int localIndexToDataIndex(int[] localIndex) { checkLocalIndexArgument(localIndex); return cpLocalIndexToDataIndex(_handle, dimensionVolume, localIndex); } + /** + * Converts a voxel index to a data index + * @param voxelIndex the voxel index to convert + * @return the buffer offset for the voxel index + */ + public int voxelIndexToDataIndex(int[] voxelIndex) { + checkLocalIndexArgument(voxelIndex); + return cpVoxelIndexToDataIndex(_handle, dimensionVolume, voxelIndex); + } + + /** + * Converts a voxel index to a data index + * @param localChunkIndex the local chunk index to convert + * @return the buffer offset for the local chunk index + */ + public int localChunkIndexToDataIndex(int[] localChunkIndex) { + checkLocalIndexArgument(localChunkIndex); + return cpLocalChunkIndexToDataIndex(_handle, dimensionVolume, localChunkIndex); + } + + private void checkLocalIndexArgument(int[] localIndex) { if (localIndex == null || localIndex.length != dimensionVolume) { throw new IllegalArgumentException("Local index size must match indexer dimension. Expected " + dimensionVolume + ", got " + (localIndex != null ? localIndex.length : "null")); diff --git a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp index 670ee1e2..f596bca1 100644 --- a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp +++ b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp @@ -100,9 +100,9 @@ getScaleOffsetForFormat(float min, float max, bool novalue, OpenVDS::VolumeDataC int main(int argc, char *argv[]) { - int32_t samplesX = 500; - int32_t samplesY = 500; - int32_t samplesZ = 250; + int32_t samplesX = 600; + int32_t samplesY = 600; + int32_t samplesZ = 300; OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_64; @@ -166,7 +166,7 @@ main(int argc, char *argv[]) { //ASSERT_TRUE(accessManager); int32_t channel = 0; - OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); + OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, channel, 0, 1000, OpenVDS::VolumeDataAccessManager::AccessMode_Create); //ASSERT_TRUE(pageAccessor); int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); @@ -188,7 +188,7 @@ main(int argc, char *argv[]) { numSamples[j] = outputIndexer.GetDataBlockNumSamples(j); } - std::cout << "\tChunk dim = " << numSamples[0] << " " << numSamples[1] << " " << numSamples[2] << "\n"; + std::cout << "\tChunk " << i << " dim = " << numSamples[0] << " " << numSamples[1] << " " << numSamples[2] << "\n"; int pitch[OpenVDS::Dimensionality_Max]; void *buffer = page->GetWritableBuffer(pitch); -- GitLab From 3950182871d561afa4ac8088cfbec92e67dbb731 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Fri, 16 Apr 2021 18:01:36 +0200 Subject: [PATCH 014/194] VolumeDataPage : read/write float buffer array Conversion method added in VolumeIndexerBase TODO : clean unit test TODO : benchmark java/cpp --- java/cpp/src/VolumeDataPage.cpp | 25 +- java/cpp/src/VolumeIndexerBase.cpp | 258 +++++++++++++----- java/java/demo/CreateVDS.java | 117 ++++---- .../org/opengroup/openvds/VolumeDataPage.java | 51 ++-- .../opengroup/openvds/VolumeIndexerBase.java | 33 +++ .../openvds/MetaDataContainerTest.java | 2 + .../opengroup/openvds/PageAccessorTest.java | 6 +- tools/ScratchVDSFileCreate/VDSFileCreate.cpp | 47 +--- 8 files changed, 333 insertions(+), 206 deletions(-) diff --git a/java/cpp/src/VolumeDataPage.cpp b/java/cpp/src/VolumeDataPage.cpp index be3deb7f..d01517b8 100644 --- a/java/cpp/src/VolumeDataPage.cpp +++ b/java/cpp/src/VolumeDataPage.cpp @@ -92,14 +92,12 @@ extern "C" { int cMax[OpenVDS::Dimensionality_Max]; GetVolumePage(handle)->GetMinMax(cMin, cMax); - int chunk_size_i = cMax[2] - cMin[2]; - int chunk_size_x = cMax[1] - cMin[1]; - int chunk_size_z = cMax[0] - cMin[0]; + int chunk_size_y = cMax[2] - cMin[2]; - char* readData = reinterpret_cast(GetVolumePage(handle)->GetWritableBuffer(pitch)); + const char* readData = reinterpret_cast(GetVolumePage(handle)->GetBuffer(pitch)); env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); - int nbElem = chunk_size_i * chunk_size_x * chunk_size_z; + int nbElem = chunk_size_y * pitch[2]; return NewJByteArray(env, readData, nbElem); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -116,7 +114,6 @@ extern "C" { try { OpenVDS::VolumeDataPage * page = GetVolumePage(handle); int pitch[OpenVDS::Dimensionality_Max]; - std::cout << "\tGet writable buffer in JNI SetByteBuffer" << std::endl; unsigned char* pageBuffer = reinterpret_cast(page->GetWritableBuffer(pitch)); int valueSize = env->GetArrayLength(values); jbyte *src = env->GetByteArrayElements(values, 0); @@ -141,14 +138,12 @@ extern "C" { int cMax[OpenVDS::Dimensionality_Max]; GetVolumePage(handle)->GetMinMax(cMin, cMax); - int chunk_size_i = cMax[2] - cMin[2]; - int chunk_size_x = cMax[1] - cMin[1]; - int chunk_size_z = cMax[0] - cMin[0]; + int chunk_size_y = cMax[2] - cMin[2]; - float* readData = static_cast(GetVolumePage(handle)->GetWritableBuffer(pitch)); + const float* readData = static_cast(GetVolumePage(handle)->GetBuffer(pitch)); env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); - int nbElem = chunk_size_i * chunk_size_x * chunk_size_z; + int nbElem = chunk_size_y * pitch[2]; return NewJFloatArray(env, readData, nbElem); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -190,14 +185,12 @@ extern "C" { int cMax[OpenVDS::Dimensionality_Max]; GetVolumePage(handle)->GetMinMax(cMin, cMax); - int chunk_size_i = cMax[2] - cMin[2]; - int chunk_size_x = cMax[1] - cMin[1]; - int chunk_size_z = cMax[0] - cMin[0]; + int chunk_size_j = cMax[2] - cMin[2]; - double* readData = reinterpret_cast(GetVolumePage(handle)->GetWritableBuffer(pitch)); + const double* readData = reinterpret_cast(GetVolumePage(handle)->GetBuffer(pitch)); env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); - int nbElem = chunk_size_i * chunk_size_x * chunk_size_z; + int nbElem = chunk_size_j * pitch[2]; return NewJDoubleArray(env, readData, nbElem); } CATCH_EXCEPTIONS_FOR_JAVA; diff --git a/java/cpp/src/VolumeIndexerBase.cpp b/java/cpp/src/VolumeIndexerBase.cpp index 83349ba5..b8420645 100644 --- a/java/cpp/src/VolumeIndexerBase.cpp +++ b/java/cpp/src/VolumeIndexerBase.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace OpenVDS; @@ -47,61 +48,61 @@ extern "C" { return (VolumeIndexer6D*)CheckHandle( handle ); } - inline void fillIntVector2(IntVector2 iv, std::vector source) { + inline void fillIntVector2(IntVector2* iv, std::vector source) { for (int i = 0; i < 2 ; ++i) { - iv[i] = source[i]; + (*iv)[i] = source[i]; } } - inline void fillIntVector3(IntVector3 iv, std::vector source) { + inline void fillIntVector3(IntVector3* iv, std::vector source) { for (int i = 0; i < 3 ; ++i) { - iv[i] = source[i]; + (*iv)[i] = source[i]; } } - inline void fillIntVector4(IntVector4 iv, std::vector source) { + inline void fillIntVector4(IntVector4* iv, std::vector source) { for (int i = 0; i < 4 ; ++i) { - iv[i] = source[i]; + (*iv)[i] = source[i]; } } - inline void fillIntVector5(IntVector<5> iv, std::vector source) { + inline void fillIntVector5(IntVector<5>* iv, std::vector source) { for (int i = 0; i < 5 ; ++i) { - iv[i] = source[i]; + (*iv)[i] = source[i]; } } - inline void fillIntVector6(IntVector<6> iv, std::vector source) { + inline void fillIntVector6(IntVector<6>* iv, std::vector source) { for (int i = 0; i < 6 ; ++i) { - iv[i] = source[i]; + (*iv)[i] = source[i]; } } - inline void fillIntArrayFromVector2(int array[], IntVector2 vec2) { + inline void fillIntArrayFromVector2(int array[], IntVector2& vec2) { for (int i = 0 ; i < 2 ; ++i) { array[i] = vec2[i]; } } - inline void fillIntArrayFromVector3(int array[], IntVector3 vec3) { + inline void fillIntArrayFromVector3(int array[], IntVector3& vec3) { for (int i = 0 ; i < 3 ; ++i) { array[i] = vec3[i]; } } - inline void fillIntArrayFromVector4(int array[], IntVector4 vec4) { + inline void fillIntArrayFromVector4(int array[], IntVector4& vec4) { for (int i = 0 ; i < 4 ; ++i) { array[i] = vec4[i]; } } - inline void fillIntArrayFromVector5(int array[], IntVector<5> vec5) { + inline void fillIntArrayFromVector5(int array[], IntVector<5>& vec5) { for (int i = 0 ; i < 5 ; ++i) { array[i] = vec5[i]; } } - inline void fillIntArrayFromVector6(int array[], IntVector<6> vec6) { + inline void fillIntArrayFromVector6(int array[], IntVector<6>& vec6) { for (int i = 0 ; i < 6 ; ++i) { array[i] = vec6[i]; } @@ -256,35 +257,35 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecLI); + fillIntVector2(&vec2, vecLI); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToVoxelIndex(vec2); fillIntArrayFromVector2(arrayRes, res2); break; } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecLI); + fillIntVector3(&vec3, vecLI); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToVoxelIndex(vec3); fillIntArrayFromVector3(arrayRes, res3); break; } case 4:{ IntVector4 vec4; - fillIntVector4(vec4, vecLI); + fillIntVector4(&vec4, vecLI); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToVoxelIndex(vec4); fillIntArrayFromVector4(arrayRes, res4); break; } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecLI); + fillIntVector5(&vec5, vecLI); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToVoxelIndex(vec5); fillIntArrayFromVector5(arrayRes, res5); break; } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecLI); + fillIntVector6(&vec6, vecLI); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToVoxelIndex(vec6); fillIntArrayFromVector6(arrayRes, res6); break; @@ -310,35 +311,35 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecLI); + fillIntVector2(&vec2, vecLI); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToLocalChunkIndex(vec2); fillIntArrayFromVector2(arrayRes, res2); break; } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecLI); + fillIntVector3(&vec3, vecLI); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToLocalChunkIndex(vec3); fillIntArrayFromVector3(arrayRes, res3); break; } case 4: { IntVector4 vec4; - fillIntVector4(vec4, vecLI); + fillIntVector4(&vec4, vecLI); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToLocalChunkIndex(vec4); fillIntArrayFromVector4(arrayRes, res4); break; } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecLI); + fillIntVector5(&vec5, vecLI); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToLocalChunkIndex(vec5); fillIntArrayFromVector5(arrayRes, res5); break; } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecLI); + fillIntVector6(&vec6, vecLI); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToLocalChunkIndex(vec6); fillIntArrayFromVector6(arrayRes, res6); break; @@ -364,35 +365,35 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecVI); + fillIntVector2(&vec2, vecVI); IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalIndex(vec2); fillIntArrayFromVector2(arrayRes, res2); break; } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecVI); + fillIntVector3(&vec3, vecVI); IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalIndex(vec3); fillIntArrayFromVector3(arrayRes, res3); break; } case 4: { IntVector4 vec4; - fillIntVector4(vec4, vecVI); + fillIntVector4(&vec4, vecVI); IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalIndex(vec4); fillIntArrayFromVector4(arrayRes, res4); break; } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecVI); + fillIntVector5(&vec5, vecVI); IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalIndex(vec5); fillIntArrayFromVector5(arrayRes, res5); break; } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecVI); + fillIntVector6(&vec6, vecVI); IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalIndex(vec6); fillIntArrayFromVector6(arrayRes, res6); break; @@ -418,35 +419,35 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecVI); + fillIntVector2(&vec2, vecVI); IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalChunkIndex(vec2); fillIntArrayFromVector2(arrayRes, res2); break; } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecVI); + fillIntVector3(&vec3, vecVI); IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalChunkIndex(vec3); fillIntArrayFromVector3(arrayRes, res3); break; } case 4: { IntVector4 vec4; - fillIntVector4(vec4, vecVI); + fillIntVector4(&vec4, vecVI); IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalChunkIndex(vec4); fillIntArrayFromVector4(arrayRes, res4); break; } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecVI); + fillIntVector5(&vec5, vecVI); IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalChunkIndex(vec5); fillIntArrayFromVector5(arrayRes, res5); break; } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecVI); + fillIntVector6(&vec6, vecVI); IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalChunkIndex(vec6); fillIntArrayFromVector6(arrayRes, res6); break; @@ -472,35 +473,35 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecLCI); + fillIntVector2(&vec2, vecLCI); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToLocalIndex(vec2); fillIntArrayFromVector2(arrayRes, res2); break; } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecLCI); + fillIntVector3(&vec3, vecLCI); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToLocalIndex(vec3); fillIntArrayFromVector3(arrayRes, res3); break; } case 4: { IntVector4 vec4; - fillIntVector4(vec4, vecLCI); + fillIntVector4(&vec4, vecLCI); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToLocalIndex(vec4); fillIntArrayFromVector4(arrayRes, res4); break; } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecLCI); + fillIntVector5(&vec5, vecLCI); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToLocalIndex(vec5); fillIntArrayFromVector5(arrayRes, res5); break; } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecLCI); + fillIntVector6(&vec6, vecLCI); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToLocalIndex(vec6); fillIntArrayFromVector6(arrayRes, res6); break; @@ -526,35 +527,35 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecLCI); + fillIntVector2(&vec2, vecLCI); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToVoxelIndex(vec2); fillIntArrayFromVector2(arrayRes, res2); break; } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecLCI); + fillIntVector3(&vec3, vecLCI); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToVoxelIndex(vec3); fillIntArrayFromVector3(arrayRes, res3); break; } case 4: { IntVector4 vec4; - fillIntVector4(vec4, vecLCI); + fillIntVector4(&vec4, vecLCI); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToVoxelIndex(vec4); fillIntArrayFromVector4(arrayRes, res4); break; } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecLCI); + fillIntVector5(&vec5, vecLCI); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToVoxelIndex(vec5); fillIntArrayFromVector5(arrayRes, res5); break; } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecLCI); + fillIntVector6(&vec6, vecLCI); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToVoxelIndex(vec6); fillIntArrayFromVector6(arrayRes, res6); break; @@ -579,27 +580,27 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecLI); + fillIntVector2(&vec2, vecLI); return GetVolumeIndexer2D(handle)->LocalIndexToDataIndex(vec2); } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecLI); + fillIntVector3(&vec3, vecLI); return GetVolumeIndexer3D(handle)->LocalIndexToDataIndex(vec3); } case 4: { IntVector4 vec4; - fillIntVector4(vec4, vecLI); + fillIntVector4(&vec4, vecLI); return GetVolumeIndexer4D(handle)->LocalIndexToDataIndex(vec4); } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecLI); + fillIntVector5(&vec5, vecLI); return GetVolumeIndexer5D(handle)->LocalIndexToDataIndex(vec5); } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecLI); + fillIntVector6(&vec6, vecLI); return GetVolumeIndexer6D(handle)->LocalIndexToDataIndex(vec6); } } @@ -621,27 +622,27 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecLI); + fillIntVector2(&vec2, vecLI); return GetVolumeIndexer2D(handle)->VoxelIndexToDataIndex(vec2); } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecLI); + fillIntVector3(&vec3, vecLI); return GetVolumeIndexer3D(handle)->VoxelIndexToDataIndex(vec3); } case 4: { IntVector4 vec4; - fillIntVector4(vec4, vecLI); + fillIntVector4(&vec4, vecLI); return GetVolumeIndexer4D(handle)->VoxelIndexToDataIndex(vec4); } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecLI); + fillIntVector5(&vec5, vecLI); return GetVolumeIndexer5D(handle)->VoxelIndexToDataIndex(vec5); } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecLI); + fillIntVector6(&vec6, vecLI); return GetVolumeIndexer6D(handle)->VoxelIndexToDataIndex(vec6); } } @@ -663,28 +664,28 @@ extern "C" { switch (volumeDimension) { case 2: { IntVector2 vec2; - fillIntVector2(vec2, vecLI); - return GetVolumeIndexer2D(handle)->LocalIndexToDataIndex(vec2); + fillIntVector2(&vec2, vecLI); + return GetVolumeIndexer2D(handle)->LocalChunkIndexToDataIndex(vec2); } case 3: { IntVector3 vec3; - fillIntVector3(vec3, vecLI); - return GetVolumeIndexer3D(handle)->LocalIndexToDataIndex(vec3); + fillIntVector3(&vec3, vecLI); + return GetVolumeIndexer3D(handle)->LocalChunkIndexToDataIndex(vec3); } case 4: { IntVector4 vec4; - fillIntVector4(vec4, vecLI); - return GetVolumeIndexer4D(handle)->LocalIndexToDataIndex(vec4); + fillIntVector4(&vec4, vecLI); + return GetVolumeIndexer4D(handle)->LocalChunkIndexToDataIndex(vec4); } case 5: { IntVector<5> vec5; - fillIntVector5(vec5, vecLI); - return GetVolumeIndexer5D(handle)->LocalIndexToDataIndex(vec5); + fillIntVector5(&vec5, vecLI); + return GetVolumeIndexer5D(handle)->LocalChunkIndexToDataIndex(vec5); } case 6: { IntVector<6> vec6; - fillIntVector6(vec6, vecLI); - return GetVolumeIndexer6D(handle)->LocalIndexToDataIndex(vec6); + fillIntVector6(&vec6, vecLI); + return GetVolumeIndexer6D(handle)->LocalChunkIndexToDataIndex(vec6); } } } @@ -692,6 +693,133 @@ extern "C" { return -1; } + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpVoxelIndexInProcessArea + * Signature: (JI[I)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) + { + try { + std::vector vecVI = JArrayToVector(env, voxelIndex); + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(&vec2, vecVI); + return GetVolumeIndexer2D(handle)->VoxelIndexInProcessArea(vec2); + } + case 3: { + IntVector3 vec3; + fillIntVector3(&vec3, vecVI); + return GetVolumeIndexer3D(handle)->VoxelIndexInProcessArea(vec3); + } + case 4: { + IntVector4 vec4; + fillIntVector4(&vec4, vecVI); + return GetVolumeIndexer4D(handle)->VoxelIndexInProcessArea(vec4); + } + case 5: { + IntVector<5> vec5; + fillIntVector5(&vec5, vecVI); + return GetVolumeIndexer5D(handle)->VoxelIndexInProcessArea(vec5); + } + case 6: { + IntVector<6> vec6; + fillIntVector6(&vec6, vecVI); + return GetVolumeIndexer6D(handle)->VoxelIndexInProcessArea(vec6); + } + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpLocalIndexInProcessArea + * Signature: (JI[I)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) + { + try { + std::vector vecLI = JArrayToVector(env, localIndex); + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(&vec2, vecLI); + return GetVolumeIndexer2D(handle)->LocalIndexInProcessArea(vec2); + } + case 3: { + IntVector3 vec3; + fillIntVector3(&vec3, vecLI); + return GetVolumeIndexer3D(handle)->LocalIndexInProcessArea(vec3); + } + case 4: { + IntVector4 vec4; + fillIntVector4(&vec4, vecLI); + return GetVolumeIndexer4D(handle)->LocalIndexInProcessArea(vec4); + } + case 5: { + IntVector<5> vec5; + fillIntVector5(&vec5, vecLI); + return GetVolumeIndexer5D(handle)->LocalIndexInProcessArea(vec5); + } + case 6: { + IntVector<6> vec6; + fillIntVector6(&vec6, vecLI); + return GetVolumeIndexer6D(handle)->LocalIndexInProcessArea(vec6); + } + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexerBase + * Method: cpLocalChunkIndexInProcessArea + * Signature: (JI[I)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) + { + try { + std::vector vecLCI = JArrayToVector(env, localChunkIndex); + switch (volumeDimension) { + case 2: { + IntVector2 vec2; + fillIntVector2(&vec2, vecLCI); + return GetVolumeIndexer2D(handle)->LocalChunkIndexInProcessArea(vec2); + } + case 3: { + IntVector3 vec3; + fillIntVector3(&vec3, vecLCI); + return GetVolumeIndexer3D(handle)->LocalChunkIndexInProcessArea(vec3); + } + case 4: { + IntVector4 vec4; + fillIntVector4(&vec4, vecLCI); + return GetVolumeIndexer4D(handle)->LocalChunkIndexInProcessArea(vec4); + } + case 5: { + IntVector<5> vec5; + fillIntVector5(&vec5, vecLCI); + return GetVolumeIndexer5D(handle)->LocalChunkIndexInProcessArea(vec5); + } + case 6: { + IntVector<6> vec6; + fillIntVector6(&vec6, vecLCI); + return GetVolumeIndexer6D(handle)->LocalChunkIndexInProcessArea(vec6); + } + } + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + + } + #ifdef __cplusplus } diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index db66bcd4..5f7ae4b1 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -1,16 +1,25 @@ import org.opengroup.openvds.*; -import sun.awt.X11.XSystemTrayPeer; +import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.List; -import java.util.Random; public class CreateVDS { public static void main(String[] args) { try { + Instant start = Instant.now(); process(args); - } catch (Throwable t) { + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } + catch (Throwable t) { System.out.println(); t.printStackTrace(); } @@ -18,12 +27,12 @@ public class CreateVDS { static void process(String[] args) throws Exception { - int samplesX = 400; // time - int samplesY = 600; // XL - int samplesZ = 600; // IL + int samplesX = 500; // time + int samplesY = 1000; // XL + int samplesZ = 1000; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; - VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_64; + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_128; int negativeMargin = 4; int positiveMargin = 4; int brickSize2DMultiplier = 4; @@ -34,13 +43,13 @@ public class CreateVDS { List axisDescriptors = new ArrayList<>(); axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "ms", 0.0f,4.f)); - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",0f, 0f + samplesY - 1f)); - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 0f, 0f + samplesZ - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1000f, 1000f + samplesY - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); List channelDescriptors = new ArrayList<>(); - float rangeMin = -0.1234f; - float rangeMax = 0.1234f; + float rangeMin = -1f; + float rangeMax = 1f; float[] scaleOffset = getScaleOffsetForFormat(rangeMin, rangeMax, true, format); VolumeDataChannelDescriptor channelDescriptor = new VolumeDataChannelDescriptor(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, @@ -62,7 +71,7 @@ public class CreateVDS { //OpenVDS::InMemoryOpenOptions options; - VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/createMain.vds"); + VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/createJava_1000_1000_500_B128.vds"); VdsError error; MetadataContainer metadataContainer = new MetadataContainer(); @@ -102,58 +111,51 @@ public class CreateVDS { VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode //ASSERT_TRUE(pageAccessor); + int dimensionality = layout.getDimensionality(); int chunkCount = (int) pageAccessor.getChunkCount(); - System.out.println("Nombre de chunks " + chunkCount); - //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); + System.out.println("Chunk count : " + chunkCount); - Random r = new Random(); for (int i = 0; i < chunkCount; i++) { VolumeDataPage page = pageAccessor.createPage(i); - System.out.print("Page " + i + " created "); - VolumeDataLayoutDescriptor.BrickSize brickSize1 = pageAccessor.getLayout().getLayoutDescriptor().getBrickSize(); + System.out.print("Page " + (i+1) + " / " + chunkCount); VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); - //QuantizingValueConverterWithNoValue converter(outputIndexer3D.valueRangeMin, outputIndexer3D.valueRangeMax, valueRangeScale, outputIndexer3D.valueRangeMin, noValue, noValue); - int[] numSamples = new int[3]; - //OpenVDS::IntVector<3> localOutIndex; + int[] numSamplesChunk = new int[3]; + int[] numSamplesDB = new int[3]; for (int j = 0; j < 3; j++) { - numSamples[j] = outputIndexer.getDataBlockNumSamples(j); + numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); + numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); } + System.out.print(" Dimensions : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; - //float[] buffer = page.readFloatBuffer(pitch); - int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; page.getMinMax(chunkMin, chunkMax); - System.out.println("Coords page : " + chunkMin[2] + "/" + chunkMax[2] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[0] + "/" + chunkMax[0]); - int chunkSizeI = chunkMax[2] - chunkMin[2]; + + System.out.print(" Coords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[2] + "/" + chunkMax[2]); + int chunkSizeY = chunkMax[2] - chunkMin[2]; int chunkSizeX = chunkMax[1] - chunkMin[1]; int chunkSizeZ = chunkMax[0] - chunkMin[0]; - int nbElem = chunkSizeI * chunkSizeX * chunkSizeZ; - float[] bufferOut = new float[nbElem]; float[] output = page.readFloatBuffer(pitch); - //float[] output = new float[0]; + // dimension of buffer + System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); - for (int o = 0 ; o < bufferOut.length ; ++o) { - float randomValue = 0.2468f * (float)r.nextDouble(); - bufferOut[o] = -0.1234f + randomValue; - } - //void* buffer = page.getWritableBuffer(pitch); - //auto output = static_cast < float *>(buffer); + int dimPitch = pitch[dimensionality - 1] * (chunkMax[dimensionality - 1] - chunkMin[dimensionality - 1]); + int[] numSamples = numSamplesChunk; for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { - int[] localOutIndex = new int[]{iDim0, iDim1, iDim2}; - - int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localOutIndex); + int[] localChunkIndex = new int[]{iDim0, iDim1, iDim2}; + int[] localIndex = outputIndexer.localChunkIndexToLocalIndex(localChunkIndex); + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); int pos[] = new int[] { voxelIndex[0], @@ -161,24 +163,20 @@ public class CreateVDS { voxelIndex[2] }; - float value = pos[0]; + float value = (float)((iDim0 + iDim1 + iDim2)%numSamples[0]) / numSamples[0]; + value = rangeMin + 2 * value; - int i1 = outputIndexer.localIndexToDataIndex(localOutIndex); - if (i1 >= 0 && i1 < output.length) - output[i1] = value; + int iPos = outputIndexer.localIndexToDataIndex(localChunkIndex); + output[iPos] = value; } - //System.out.println("Write buffer in page " + i); - page.writeFloatBuffer(bufferOut); - - //OpenVDS::CalculateNoise3D(buffer, format, &outputIndexer, frequency, 0.021f, 0.f, true, 345); + // write buffer then release page + page.writeFloatBuffer(output, pitch, dimensionality); page.pageRelease(); } - System.out.println("Everything created"); pageAccessor.commit(); - System.out.println("Commit done"); - //pageAccessor.setMaxPages(0); + pageAccessor.setMaxPages(0); accessManager.flushUploadQueue(); accessManager.destroyVolumeDataPageAccessor(pageAccessor); @@ -186,29 +184,6 @@ public class CreateVDS { System.out.println("VDS closed"); } -// static float[] getScaleOffsetForFormat(float min, float max, boolean novalue, VolumeDataChannelDescriptor.Format format) { -// float res[] = new float[] {1f, 0f}; -// switch (format) { -// case VolumeDataChannelDescriptor.Format.FORMAT_U8: -// res[0] = 1.f / (255.f - novalue) * (max - min); -// res[1] = min; -// break; -// case VolumeDataChannelDescriptor.Format.FORMAT_U16: -// res[0] = 1.f / (65535.f - novalue) * (max - min); -// res[1] = min; -// break; -// case VolumeDataChannelDescriptor.Format.FORMAT_R32: -// case VolumeDataChannelDescriptor.Format.FORMAT_U32: -// case VolumeDataChannelDescriptor.Format.FORMAT_R64: -// case VolumeDataChannelDescriptor.Format.FORMAT_U64: -// case VolumeDataChannelDescriptor.Format.FORMAT_1BIT: -// case VolumeDataChannelDescriptor.Format.FORMAT_ANY: -// res[0] = 1.0f; -// res[1] = 0.0f; -// } -// return res; -// } - static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { float res[] = new float[] {1f, 0f}; float noValueCmp = useNoValue ? 1f : 0f; diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index 7b840d31..e878194a 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -90,9 +90,11 @@ public class VolumeDataPage extends JniPointer { /** * Set byte array int page * @param buffer values to set. Size must match page sample size + * @param pitch chunk pitch (got by a read) + * @param dimensionality volume dimensionality */ - public void writeByteBuffer(byte[] buffer) { - checkBufferSize(buffer); + public void writeByteBuffer(byte[] buffer, int[] pitch, int dimensionality) { + checkBufferSize(buffer, pitch, dimensionality); cpSetByteBuffer(_handle, buffer); } @@ -109,9 +111,11 @@ public class VolumeDataPage extends JniPointer { /** * Set float array int page * @param buffer values to set. Size must match page sample size + * @param pitch chunk pitch (got by a read) + * @param dimensionality volume dimensionality */ - public void writeFloatBuffer(float[] buffer) { - checkBufferSize(buffer); + public void writeFloatBuffer(float[] buffer, int[] pitch, int dimensionality) { + checkBufferSize(buffer, pitch, dimensionality); cpSetFloatBuffer(_handle, buffer); } @@ -128,9 +132,11 @@ public class VolumeDataPage extends JniPointer { /** * Set double array int page * @param buffer values to set. Size must match page sample size + * @param pitch chunk pitch (got by a read) + * @param dimensionality volume dimensionality */ - public void writeDoubleBuffer(double[] buffer) { - checkBufferSize(buffer); + public void writeDoubleBuffer(double[] buffer, int[] pitch, int dimensionality) { + checkBufferSize(buffer, pitch, dimensionality); cpSetDoubleBuffer(_handle, buffer); } @@ -141,24 +147,33 @@ public class VolumeDataPage extends JniPointer { return getElementCount(chunkMin, chunkMax); } - private void checkBufferSize(byte[] buffer) { - int elementCount = getElementCount(); - if (buffer == null || buffer.length != elementCount) { - throw new IllegalArgumentException("Wrong buffer size, expected " + elementCount + ", got " + (buffer == null ? "null" : buffer.length)); + private void checkBufferSize(byte[] buffer, int[] pitch, int dim) { + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + getMinMax(chunkMin, chunkMax); + int nbElem = (chunkMax[dim - 1] - chunkMin[dim - 1]) * pitch[dim - 1]; + if (buffer == null || buffer.length != nbElem) { + throw new IllegalArgumentException("Wrong buffer size, expected " + nbElem + "(dim2 * pitch[2]), got " + (buffer == null ? "null" : buffer.length)); } } - private void checkBufferSize(float[] buffer) { - int elementCount = getElementCount(); - if (buffer == null || buffer.length != elementCount) { - throw new IllegalArgumentException("Wrong buffer size, expected " + elementCount + ", got " + (buffer == null ? "null" : buffer.length)); + private void checkBufferSize(float[] buffer, int[] pitch, int dim) { + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + getMinMax(chunkMin, chunkMax); + int nbElem = (chunkMax[dim - 1] - chunkMin[dim - 1]) * pitch[dim - 1]; + if (buffer == null || buffer.length != nbElem) { + throw new IllegalArgumentException("Wrong buffer size, expected " + nbElem + "(dim2 * pitch[2]), got " + (buffer == null ? "null" : buffer.length)); } } - private void checkBufferSize(double[] buffer) { - int elementCount = getElementCount(); - if (buffer == null || buffer.length != elementCount) { - throw new IllegalArgumentException("Wrong buffer size, expected " + elementCount + ", got " + (buffer == null ? "null" : buffer.length)); + private void checkBufferSize(double[] buffer, int[] pitch, int dim) { + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + getMinMax(chunkMin, chunkMax); + int nbElem = (chunkMax[dim - 1] - chunkMin[dim - 1]) * pitch[dim - 1]; + if (buffer == null || buffer.length != nbElem) { + throw new IllegalArgumentException("Wrong buffer size, expected " + nbElem + "(dim2 * pitch[2]), got " + (buffer == null ? "null" : buffer.length)); } } diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java index 9ffbb3cd..8f687cc8 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java @@ -22,6 +22,10 @@ public abstract class VolumeIndexerBase extends JniPointer { private static native int cpVoxelIndexToDataIndex(long handle, int volumeDimension, int[] voxelIndex); private static native int cpLocalChunkIndexToDataIndex(long handle, int volumeDimension, int[] localChunkIndex); + private static native boolean cpVoxelIndexInProcessArea(long handle, int volumeDimension, int[] voxelIndex); + private static native boolean cpLocalIndexInProcessArea(long handle, int volumeDimension, int[] voxelIndex); + private static native boolean cpLocalChunkIndexInProcessArea(long handle, int volumeDimension, int[] voxelIndex); + private final int dimensionVolume; public VolumeIndexerBase(long handle, int dimension, boolean ownHandle) { @@ -152,6 +156,35 @@ public abstract class VolumeIndexerBase extends JniPointer { return cpLocalChunkIndexToDataIndex(_handle, dimensionVolume, localChunkIndex); } + /** + * Checks if a voxel index is within the chunk this indexer was created with + * @param voxelIndex the voxel index to check + * @return true if the index is within this chunk, false otherwise + */ + public boolean voxelIndexInProcessArea(int[] voxelIndex) { + checkLocalIndexArgument(voxelIndex); + return cpVoxelIndexInProcessArea(_handle, dimensionVolume, voxelIndex); + } + + /** + * Checks if a local index is within the chunk this indexer was created with + * @param localIndex the local index to check + * @return true if the index is within this chunk, false otherwise + */ + public boolean localIndexInProcessArea(int[] localIndex) { + checkLocalIndexArgument(localIndex); + return cpLocalIndexInProcessArea(_handle, dimensionVolume, localIndex); + } + + /** + * Checks if a local chunk index is within the chunk this indexer was created with + * @param localChunkIndex the local chunk index to check + * @return true if the index is within this chunk, false otherwise + */ + public boolean localChunkIndexInProcessArea(int[] localChunkIndex) { + checkLocalIndexArgument(localChunkIndex); + return cpLocalChunkIndexInProcessArea(_handle, dimensionVolume, localChunkIndex); + } private void checkLocalIndexArgument(int[] localIndex) { if (localIndex == null || localIndex.length != dimensionVolume) { diff --git a/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java b/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java index 967bbd15..92a0c96e 100644 --- a/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java +++ b/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java @@ -218,6 +218,8 @@ public class MetaDataContainerTest { metaData.setMetadataString("categoryString", "String", mdString); + // TODO : create fils in tmp dir + System.getProperty("java.io.tmpdir"); VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testCreate.vds"); VdsError vdsError = new VdsError(); OpenVDS createdVDS = OpenVDS.create(options, ld, vda, vdc, metaData); diff --git a/java/java/test/org/opengroup/openvds/PageAccessorTest.java b/java/java/test/org/opengroup/openvds/PageAccessorTest.java index 616de482..331731a8 100644 --- a/java/java/test/org/opengroup/openvds/PageAccessorTest.java +++ b/java/java/test/org/opengroup/openvds/PageAccessorTest.java @@ -61,6 +61,8 @@ public class PageAccessorTest { @Test public void testVolumeIndexerCreationDeletion() { try { + // TODO : create fils in tmp dir + System.getProperty("java.io.tmpdir"); VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testVolumeIndexer.vds"); VdsHandle vdsTest = OpenVDS.create(options, ld, vda, @@ -154,7 +156,7 @@ public class PageAccessorTest { int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localOutIndex); - int pos[] = new int[]{ + int pos[] = new int[] { voxelIndex[0], voxelIndex[1], voxelIndex[2] @@ -174,7 +176,7 @@ public class PageAccessorTest { System.out.println(""); System.out.println("\t" + smp + " samples will be written"); System.out.println("\tWill write buffer " + i); - page.writeFloatBuffer(buffer); + page.writeFloatBuffer(buffer, pitch, layout.getDimensionality()); System.out.println("\tDone write buffer " + i); //page.writeDoubleBuffer(buffer); //page.writeByteBuffer(buffer); diff --git a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp index f596bca1..50896669 100644 --- a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp +++ b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp @@ -100,8 +100,8 @@ getScaleOffsetForFormat(float min, float max, bool novalue, OpenVDS::VolumeDataC int main(int argc, char *argv[]) { - int32_t samplesX = 600; - int32_t samplesY = 600; + int32_t samplesX = 200; + int32_t samplesY = 300; int32_t samplesZ = 300; OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; @@ -115,16 +115,13 @@ main(int argc, char *argv[]) { brickSize2DMultiplier, lodLevels, layoutOptions); std::vector axisDescriptors; - axisDescriptors.emplace_back(samplesX, "Sample", "ms", 0.0f, - 4.f); - axisDescriptors.emplace_back(samplesY, "Crossline", "", - 1932.f, 2536.f); - axisDescriptors.emplace_back(samplesZ, "Inline", "", 9985.f, - 10369.f); + axisDescriptors.emplace_back(samplesX, "Sample", "ms", 0.0f,4.f); + axisDescriptors.emplace_back(samplesY, "Crossline", "",1932.f, 1932.f + samplesY - 1.f); + axisDescriptors.emplace_back(samplesZ, "Inline", "", 9985.f, 9985.f + samplesZ - 1.f); std::vector channelDescriptors; - float rangeMin = -0.1234f; - float rangeMax = 0.1234f; + float rangeMin = -1.f; + float rangeMax = 1.f; float intScale; float intOffset; getScaleOffsetForFormat(rangeMin, rangeMax, true, format, intScale, intOffset); @@ -134,7 +131,7 @@ main(int argc, char *argv[]) { OpenVDS::VolumeDataChannelDescriptor::Default, 0.f, intScale, intOffset); //OpenVDS::InMemoryOpenOptions options; - OpenVDS::VDSFileOpenOptions options("/tmp/createCPP.vds"); + OpenVDS::VDSFileOpenOptions options("/tmp/createCPP_bis.vds"); OpenVDS::Error error; OpenVDS::MetadataContainer metadataContainer; @@ -155,7 +152,6 @@ main(int argc, char *argv[]) { metadataContainer.SetMetadataDoubleVector4("categoryDouble", "DoubleVector4", OpenVDS::DoubleVector4(45.5, 78.75, 72.75, 84.1)); metadataContainer.SetMetadataString("categoryString", "String", std::string("Test string")); -//metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); auto vds = OpenVDS::Create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, error); @@ -170,51 +166,34 @@ main(int argc, char *argv[]) { //ASSERT_TRUE(pageAccessor); int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); - std::cout << "Chunk Count = " << chunkCount << "\n"; //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); for (int i = 0; i < chunkCount; i++) { OpenVDS::VolumeDataPage *page = pageAccessor->CreatePage(i); OpenVDS::VolumeIndexer3D outputIndexer(page, 0, 0, OpenVDS::Dimensions_012, layout); - - //float valueRangeScale = outputIndexer.valueRangeMax - outputIndexer.valueRangeMin; - //QuantizingValueConverterWithNoValue converter(outputIndexer3D.valueRangeMin, outputIndexer3D.valueRangeMax, valueRangeScale, outputIndexer3D.valueRangeMin, noValue, noValue); - OpenVDS::IntVector<3> numSamples; - //OpenVDS::IntVector<3> localOutIndex; for (int j=0; j<3; j++) { numSamples[j] = outputIndexer.GetDataBlockNumSamples(j); } - std::cout << "\tChunk " << i << " dim = " << numSamples[0] << " " << numSamples[1] << " " << numSamples[2] << "\n"; - int pitch[OpenVDS::Dimensionality_Max]; void *buffer = page->GetWritableBuffer(pitch); - auto output = static_cast(buffer); for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { - OpenVDS::IntVector<3> - localOutIndex(iDim0, iDim1, iDim2); - - OpenVDS::IntVector<3> - voxelIndex = outputIndexer.LocalIndexToVoxelIndex(localOutIndex); - - int pos[3] = { voxelIndex[0], - voxelIndex[1], - voxelIndex[2]}; - - float value = pos[0]; + OpenVDS::IntVector<3> localOutIndex(iDim0, iDim1, iDim2); - output[outputIndexer.LocalIndexToDataIndex(localOutIndex)] = value; + float value = (float) ((iDim0 + iDim1 + iDim2)%numSamples[0]) / numSamples[0]; + value = rangeMin + 2.f * value; + int dataPos = outputIndexer.LocalIndexToDataIndex(localOutIndex); + output[dataPos] = value; } - //OpenVDS::CalculateNoise3D(buffer, format, &outputIndexer, frequency, 0.021f, 0.f, true, 345); page->Release(); } -- GitLab From 5c101dd9802119f0700774e9226398533f063c27 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Mon, 19 Apr 2021 10:19:22 +0200 Subject: [PATCH 015/194] Unit test : use java system temp directory, clean after execution Unit test : test copy --- .../openvds/MetaDataContainerTest.java | 23 +- .../opengroup/openvds/PageAccessorTest.java | 203 +++++++++++------- 2 files changed, 141 insertions(+), 85 deletions(-) diff --git a/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java b/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java index 92a0c96e..077d3290 100644 --- a/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java +++ b/java/java/test/org/opengroup/openvds/MetaDataContainerTest.java @@ -1,13 +1,18 @@ package org.opengroup.openvds; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.io.File; + import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; public class MetaDataContainerTest { + private static String TEMP_FILE_NAME = "vdsTestMetadata.vds"; + public String url; public VolumeDataLayoutDescriptor ld; public VolumeDataAxisDescriptor[] vda; @@ -41,6 +46,16 @@ public class MetaDataContainerTest { ld = volumeDataLayout.getLayoutDescriptor(); } + @AfterClass + public void cleanTempFile() { + String tempDir = System.getProperty("java.io.tmpdir"); + String tempFilePath = tempDir + File.separator + TEMP_FILE_NAME; + File fileTemp = new File(tempFilePath); + if (fileTemp.exists()) { + fileTemp.delete(); + } + } + @Test void testMetadataContainer() { // creates object @@ -218,9 +233,11 @@ public class MetaDataContainerTest { metaData.setMetadataString("categoryString", "String", mdString); - // TODO : create fils in tmp dir - System.getProperty("java.io.tmpdir"); - VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testCreate.vds"); + // create file in tmp dir + String tempDir = System.getProperty("java.io.tmpdir"); + String tempFilePath = tempDir + File.separator + TEMP_FILE_NAME; + + VDSFileOpenOptions options = new VDSFileOpenOptions(tempFilePath); VdsError vdsError = new VdsError(); OpenVDS createdVDS = OpenVDS.create(options, ld, vda, vdc, metaData); diff --git a/java/java/test/org/opengroup/openvds/PageAccessorTest.java b/java/java/test/org/opengroup/openvds/PageAccessorTest.java index 331731a8..609bff62 100644 --- a/java/java/test/org/opengroup/openvds/PageAccessorTest.java +++ b/java/java/test/org/opengroup/openvds/PageAccessorTest.java @@ -1,23 +1,32 @@ package org.opengroup.openvds; +import org.testng.Assert; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; + +import java.io.File; + import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; public class PageAccessorTest { + + private static String TEMP_FILE_NAME_VOL_INDEX = "volIndexer.vds"; + private static String TEMP_FILE_NAME_COPY = "vdsCopy.vds"; + public String url; public VolumeDataLayoutDescriptor ld; public VolumeDataAxisDescriptor[] vda; public VolumeDataChannelDescriptor[] vdc; public MetadataReadAccess md; public MemoryVdsGenerator vds; - private MetadataContainer metadataContainer; + public MetadataContainer metadataContainer; @BeforeClass public void init() { - vds = new MemoryVdsGenerator(100, 100, 100, VolumeDataChannelDescriptor.Format.FORMAT_R32); + vds = new MemoryVdsGenerator(300, 300, 100, VolumeDataChannelDescriptor.Format.FORMAT_R32); url = "inmemory://create_test"; VolumeDataLayout volumeDataLayout = vds.getLayout(); @@ -58,12 +67,29 @@ public class PageAccessorTest { //metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); } + @AfterClass + public void cleanFiles() { + String tempDir = System.getProperty("java.io.tmpdir"); + String fileVolIndexPath = tempDir + File.separator + TEMP_FILE_NAME_VOL_INDEX; + File fileVolIndex = new File(fileVolIndexPath); + if (fileVolIndex.exists()) { + fileVolIndex.delete(); + } + + String fileCopyPath = tempDir + File.separator + TEMP_FILE_NAME_VOL_INDEX; + File fileCopy = new File(fileCopyPath); + if (fileCopy.exists()) { + fileCopy.delete(); + } + } + @Test public void testVolumeIndexerCreationDeletion() { try { - // TODO : create fils in tmp dir - System.getProperty("java.io.tmpdir"); - VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testVolumeIndexer.vds"); + // create file in tmp dir + String tmpDir = System.getProperty("java.io.tmpdir"); + String volIndexPath = tmpDir + File.separator + TEMP_FILE_NAME_VOL_INDEX; + VDSFileOpenOptions options = new VDSFileOpenOptions(volIndexPath); VdsHandle vdsTest = OpenVDS.create(options, ld, vda, vdc, metadataContainer); @@ -93,95 +119,48 @@ public class PageAccessorTest { } @Test - public void testCreatePageAccessor() { + public void testCopyPageAccessor() { try { - VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testPageAccessorFloat100_100_100.vds"); - VdsHandle vdsPageAccessor = OpenVDS.create(options, ld, + String tmpDir = System.getProperty("java.io.tmpdir"); + String vdsPath = tmpDir + File.separator + TEMP_FILE_NAME_COPY; + VDSFileOpenOptions options = new VDSFileOpenOptions(vdsPath); + VdsHandle vdsCopy = OpenVDS.create(options, ld, vda, vdc, metadataContainer); - VolumeDataAccessManager accessManager = vdsPageAccessor.getAccessManager(); + VolumeDataAccessManager accessManager = vdsCopy.getAccessManager(); //ASSERT_TRUE(accessManager); int channel = 0; - VolumeDataLayout layout = vdsPageAccessor.getLayout(); + VolumeDataLayout layout = vdsCopy.getLayout(); VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( layout, // layout DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND 0, // lod channel, // channel - 100, // max pages + 20, // max pages VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode - int chunkCount = (int) pageAccessor.getChunkCount(); - System.out.println("Nombre de chunks : " + chunkCount); - for (int i = 0; i < chunkCount; i++) { - VolumeDataPage page = pageAccessor.createPage(i); - System.out.println("Page created : " + i); - VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); - System.out.println("\tOutput indexer created : " + i); - - int[] numSamples = new int[3]; - for (int j = 0; j < 3; j++) { - numSamples[j] = outputIndexer.getDataBlockNumSamples(j); - } - System.out.println("\tChunk dim (" + i + ") : I " + numSamples[0] + " - X " + numSamples[1] + " - Z " + numSamples[2]); - - int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; - - page.getMinMax(chunkMin, chunkMax); - int chunkSizeI = chunkMax[2] - chunkMin[2]; - int chunkSizeX = chunkMax[1] - chunkMin[1]; - int chunkSizeZ = chunkMax[0] - chunkMin[0]; - int nbElem = chunkSizeI * chunkSizeX * chunkSizeZ; - float[] buffer = new float[nbElem]; - System.out.println("\tGot min max : " + i); - System.out.println("\tChunk coords (" + i + ") : I " + chunkMin[2] + "/" + chunkMax[2] + " - X " + chunkMin[1] + "/" + chunkMax[1] + " - Z " + chunkMin[0] + "/" + chunkMax[0]); - - //float[] buffer = page.readFloatBuffer(pitch); - //double[] buffer = page.readDoubleBuffer(pitch); - //byte[] buffer = page.readByteBuffer(pitch); - - for (int idx = 0 ; idx < buffer.length ; ++idx) { - buffer[idx] = (float) (idx % 256); - } - - int smp = 0; - for (int iDim2 = 0; iDim2 < chunkSizeI; iDim2++) { - System.out.print("."); - for (int iDim1 = 0; iDim1 < chunkSizeX; iDim1++) { - for (int iDim0 = 0; iDim0 < chunkSizeZ; iDim0++) { - int[] localOutIndex = new int[]{iDim0, iDim1, iDim2}; - - int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localOutIndex); - - int pos[] = new int[] { - voxelIndex[0], - voxelIndex[1], - voxelIndex[2] - }; - - float value = pos[0]; - //double value = pos[0]; - //byte value = (byte) (pos[0] % Byte.MAX_VALUE); - int dataIndex = outputIndexer.localIndexToDataIndex(pos); - if (dataIndex < buffer.length) { - buffer[dataIndex] = value; - ++smp; - } - } - } - } - System.out.println(""); - System.out.println("\t" + smp + " samples will be written"); - System.out.println("\tWill write buffer " + i); - page.writeFloatBuffer(buffer, pitch, layout.getDimensionality()); - System.out.println("\tDone write buffer " + i); - //page.writeDoubleBuffer(buffer); - //page.writeByteBuffer(buffer); - page.release(); - System.out.println("Page writed : " + i); + // get input manager + VolumeDataAccessManager inputAM = vds.getAccessManager(); + VolumeDataPageAccessor pageAccessorInput = inputAM.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + 0, // lod + channel, // channel + 20, // max pages + VolumeDataAccessManager.AccessMode.ReadOnly.getCode()); // access mode + int dimensionality = layout.getDimensionality(); + + // copy file + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + for (long chunk = 0 ; chunk < pageAccessorInput.getChunkCount() ; ++chunk) { + VolumeDataPage inputPage = pageAccessorInput.readPage(chunk); + VolumeDataPage page = pageAccessor.createPage(chunk); + float[] data = inputPage.readFloatBuffer(pitch); + page.writeFloatBuffer(data, pitch, dimensionality); + + inputPage.pageRelease(); + page.pageRelease(); } pageAccessor.commit(); @@ -189,11 +168,71 @@ public class PageAccessorTest { accessManager.flushUploadQueue(); accessManager.destroyVolumeDataPageAccessor(pageAccessor); - vdsPageAccessor.close(); + vdsCopy.close(); + } + catch (java.io.IOException e) { + System.out.println(e.getMessage()); + fail(); + } + } + + /** + * Will test that copied file is the same as the input + * Name of method is the same + Suffix so that it's executed after the copy test + */ + @Test + public void testCopyPageAccessorValidation() { + try { + String tmpDir = System.getProperty("java.io.tmpdir"); + String vdsPath = tmpDir + File.separator + TEMP_FILE_NAME_COPY; + VDSFileOpenOptions options = new VDSFileOpenOptions(vdsPath); + VdsHandle vdsCopy = OpenVDS.open(options); + VolumeDataAccessManager accessManager = vdsCopy.getAccessManager(); + + int channel = 0; + VolumeDataLayout layout = vdsCopy.getLayout(); + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + 0, // lod + channel, // channel + 20, // max pages + VolumeDataAccessManager.AccessMode.ReadOnly.getCode()); // access mode + + // get input manager + VolumeDataAccessManager inputAM = vds.getAccessManager(); + VolumeDataPageAccessor pageAccessorInput = inputAM.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + 0, // lod + channel, // channel + 20, // max pages + VolumeDataAccessManager.AccessMode.ReadOnly.getCode()); // access mode + + // compares block data + int[] pitchInput = new int[VolumeDataLayout.Dimensionality_Max]; + int[] pitchOutput = new int[VolumeDataLayout.Dimensionality_Max]; + for (long chunk = 0 ; chunk < pageAccessorInput.getChunkCount() ; ++chunk) { + VolumeDataPage inputPage = pageAccessorInput.readPage(chunk); + VolumeDataPage page = pageAccessor.readPage(chunk); + float[] dataIn = inputPage.readFloatBuffer(pitchInput); + float[] dataOut = page.readFloatBuffer(pitchOutput); + + Assert.assertEquals(pitchInput, pitchOutput); + Assert.assertEquals(dataIn, dataOut); + + inputPage.pageRelease(); + page.pageRelease(); + } + + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + + vdsCopy.close(); } catch (java.io.IOException e) { System.out.println(e.getMessage()); fail(); } } + } -- GitLab From 0edea0f37533c7d58450ba44bb92ba61b74220b6 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Mon, 19 Apr 2021 15:38:36 +0200 Subject: [PATCH 016/194] VolumeIndexerBase : try to speed up query. TODO : check if IntVector can be created faster Unit test : small refactor --- java/cpp/src/VolumeIndexerBase.cpp | 402 +++++++----------- java/java/demo/CreateVDS.java | 93 +++- .../org/opengroup/openvds/VolumeDataPage.java | 2 +- .../opengroup/openvds/VolumeIndexerBase.java | 36 +- .../opengroup/openvds/PageAccessorTest.java | 11 +- 5 files changed, 257 insertions(+), 287 deletions(-) diff --git a/java/cpp/src/VolumeIndexerBase.cpp b/java/cpp/src/VolumeIndexerBase.cpp index b8420645..280352b3 100644 --- a/java/cpp/src/VolumeIndexerBase.cpp +++ b/java/cpp/src/VolumeIndexerBase.cpp @@ -48,66 +48,6 @@ extern "C" { return (VolumeIndexer6D*)CheckHandle( handle ); } - inline void fillIntVector2(IntVector2* iv, std::vector source) { - for (int i = 0; i < 2 ; ++i) { - (*iv)[i] = source[i]; - } - } - - inline void fillIntVector3(IntVector3* iv, std::vector source) { - for (int i = 0; i < 3 ; ++i) { - (*iv)[i] = source[i]; - } - } - - inline void fillIntVector4(IntVector4* iv, std::vector source) { - for (int i = 0; i < 4 ; ++i) { - (*iv)[i] = source[i]; - } - } - - inline void fillIntVector5(IntVector<5>* iv, std::vector source) { - for (int i = 0; i < 5 ; ++i) { - (*iv)[i] = source[i]; - } - } - - inline void fillIntVector6(IntVector<6>* iv, std::vector source) { - for (int i = 0; i < 6 ; ++i) { - (*iv)[i] = source[i]; - } - } - - inline void fillIntArrayFromVector2(int array[], IntVector2& vec2) { - for (int i = 0 ; i < 2 ; ++i) { - array[i] = vec2[i]; - } - } - - inline void fillIntArrayFromVector3(int array[], IntVector3& vec3) { - for (int i = 0 ; i < 3 ; ++i) { - array[i] = vec3[i]; - } - } - - inline void fillIntArrayFromVector4(int array[], IntVector4& vec4) { - for (int i = 0 ; i < 4 ; ++i) { - array[i] = vec4[i]; - } - } - - inline void fillIntArrayFromVector5(int array[], IntVector<5>& vec5) { - for (int i = 0 ; i < 5 ; ++i) { - array[i] = vec5[i]; - } - } - - inline void fillIntArrayFromVector6(int array[], IntVector<6>& vec6) { - for (int i = 0 ; i < 6 ; ++i) { - array[i] = vec6[i]; - } - } - /* * Class: org_opengroup_openvds_VolumeIndexerBase * Method: cpDeleteHandle @@ -248,53 +188,46 @@ extern "C" { * Method: cpLocalIndexToVoxelIndex * Signature: (JI[I)[I */ - JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToVoxelIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex, jintArray resOutIndex) { try { - std::vector vecLI = JArrayToVector(env, localIndex); - int arrayRes[volumeDimension]; + jint *input = env->GetIntArrayElements(localIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLI); + IntVector2 vec2(input[0], input[1]); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToVoxelIndex(vec2); - fillIntArrayFromVector2(arrayRes, res2); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); break; } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLI); + IntVector3 vec3(input[0], input[1], input[2]); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToVoxelIndex(vec3); - fillIntArrayFromVector3(arrayRes, res3); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); break; } case 4:{ - IntVector4 vec4; - fillIntVector4(&vec4, vecLI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToVoxelIndex(vec4); - fillIntArrayFromVector4(arrayRes, res4); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); break; } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToVoxelIndex(vec5); - fillIntArrayFromVector5(arrayRes, res5); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); break; } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToVoxelIndex(vec6); - fillIntArrayFromVector6(arrayRes, res6); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); break; } } - return NewJIntArray(env, arrayRes, volumeDimension); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); } CATCH_EXCEPTIONS_FOR_JAVA; - return NULL; } /* @@ -302,53 +235,46 @@ extern "C" { * Method: cpLocalIndexToLocalChunkIndex * Signature: (JI[I)[I */ - JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToLocalChunkIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex, jintArray resOutIndex) { try { - std::vector vecLI = JArrayToVector(env, localIndex); - int arrayRes[volumeDimension]; + jint *input = env->GetIntArrayElements(localIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLI); + IntVector2 vec2(input[0], input[1]); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToLocalChunkIndex(vec2); - fillIntArrayFromVector2(arrayRes, res2); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); break; } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLI); + IntVector3 vec3(input[0], input[1], input[2]); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToLocalChunkIndex(vec3); - fillIntArrayFromVector3(arrayRes, res3); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); break; } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecLI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToLocalChunkIndex(vec4); - fillIntArrayFromVector4(arrayRes, res4); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); break; } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToLocalChunkIndex(vec5); - fillIntArrayFromVector5(arrayRes, res5); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); break; } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToLocalChunkIndex(vec6); - fillIntArrayFromVector6(arrayRes, res6); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); break; } } - return NewJIntArray(env, arrayRes, volumeDimension); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); } CATCH_EXCEPTIONS_FOR_JAVA; - return NULL; } /* @@ -356,53 +282,46 @@ extern "C" { * Method: cpVoxelIndexToLocalIndex * Signature: (JI[I)[I */ - JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToLocalIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex, jintArray resOutIndex) { try { - std::vector vecVI = JArrayToVector(env, voxelIndex); - int arrayRes[volumeDimension]; + jint *input = env->GetIntArrayElements(voxelIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecVI); + IntVector2 vec2(input[0], input[1]); IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalIndex(vec2); - fillIntArrayFromVector2(arrayRes, res2); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); break; } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecVI); + IntVector3 vec3(input[0], input[1], input[2]); IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalIndex(vec3); - fillIntArrayFromVector3(arrayRes, res3); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); break; } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecVI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalIndex(vec4); - fillIntArrayFromVector4(arrayRes, res4); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); break; } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecVI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalIndex(vec5); - fillIntArrayFromVector5(arrayRes, res5); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); break; } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecVI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalIndex(vec6); - fillIntArrayFromVector6(arrayRes, res6); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); break; } } - return NewJIntArray(env, arrayRes, volumeDimension); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); } CATCH_EXCEPTIONS_FOR_JAVA; - return NULL; } /* @@ -410,53 +329,46 @@ extern "C" { * Method: cpVoxelIndexToLocalChunkIndex * Signature: (JI[I)[I */ - JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToLocalChunkIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex, jintArray resOutIndex) { try { - std::vector vecVI = JArrayToVector(env, voxelIndex); - int arrayRes[volumeDimension]; + jint *input = env->GetIntArrayElements(voxelIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecVI); + IntVector2 vec2(input[0], input[1]); IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalChunkIndex(vec2); - fillIntArrayFromVector2(arrayRes, res2); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); break; } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecVI); + IntVector3 vec3(input[0], input[1], input[2]); IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalChunkIndex(vec3); - fillIntArrayFromVector3(arrayRes, res3); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); break; } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecVI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalChunkIndex(vec4); - fillIntArrayFromVector4(arrayRes, res4); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); break; } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecVI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalChunkIndex(vec5); - fillIntArrayFromVector5(arrayRes, res5); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); break; } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecVI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalChunkIndex(vec6); - fillIntArrayFromVector6(arrayRes, res6); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); break; } } - return NewJIntArray(env, arrayRes, volumeDimension); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); } CATCH_EXCEPTIONS_FOR_JAVA; - return NULL; } /* @@ -464,53 +376,46 @@ extern "C" { * Method: cpLocalChunkIndexToLocalIndex * Signature: (JI[I)[I */ - JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToLocalIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex, jintArray resOutIndex) { try { - std::vector vecLCI = JArrayToVector(env, localChunkIndex); - int arrayRes[volumeDimension]; + jint *input = env->GetIntArrayElements(localChunkIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLCI); + IntVector2 vec2(input[0], input[1]); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToLocalIndex(vec2); - fillIntArrayFromVector2(arrayRes, res2); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); break; } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLCI); + IntVector3 vec3(input[0], input[1], input[2]); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToLocalIndex(vec3); - fillIntArrayFromVector3(arrayRes, res3); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); break; } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecLCI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToLocalIndex(vec4); - fillIntArrayFromVector4(arrayRes, res4); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); break; } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLCI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToLocalIndex(vec5); - fillIntArrayFromVector5(arrayRes, res5); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); break; } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLCI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToLocalIndex(vec6); - fillIntArrayFromVector6(arrayRes, res6); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); break; } } - return NewJIntArray(env, arrayRes, volumeDimension); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); } CATCH_EXCEPTIONS_FOR_JAVA; - return NULL; } /* @@ -518,53 +423,46 @@ extern "C" { * Method: cpLocalChunkIndexToVoxelIndex * Signature: (JI[I)[I */ - JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToVoxelIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex, jintArray resOutIndex) { try { - std::vector vecLCI = JArrayToVector(env, localChunkIndex); - int arrayRes[volumeDimension]; + jint *input = env->GetIntArrayElements(localChunkIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLCI); + IntVector2 vec2(input[0], input[1]); IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToVoxelIndex(vec2); - fillIntArrayFromVector2(arrayRes, res2); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); break; } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLCI); + IntVector3 vec3(input[0], input[1], input[2]); IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToVoxelIndex(vec3); - fillIntArrayFromVector3(arrayRes, res3); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); break; } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecLCI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToVoxelIndex(vec4); - fillIntArrayFromVector4(arrayRes, res4); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); break; } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLCI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToVoxelIndex(vec5); - fillIntArrayFromVector5(arrayRes, res5); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); break; } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLCI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToVoxelIndex(vec6); - fillIntArrayFromVector6(arrayRes, res6); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); break; } } - return NewJIntArray(env, arrayRes, volumeDimension); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); } CATCH_EXCEPTIONS_FOR_JAVA; - return NULL; } /* @@ -576,31 +474,31 @@ extern "C" { (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) { try { - std::vector vecLI = JArrayToVector(env, localIndex); + jint *input = env->GetIntArrayElements(localIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLI); + IntVector2 vec2(input[0], input[1]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer2D(handle)->LocalIndexToDataIndex(vec2); } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLI); + IntVector3 vec3(input[0], input[1], input[2]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer3D(handle)->LocalIndexToDataIndex(vec3); } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecLI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer4D(handle)->LocalIndexToDataIndex(vec4); } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer5D(handle)->LocalIndexToDataIndex(vec5); } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer6D(handle)->LocalIndexToDataIndex(vec6); } } @@ -618,31 +516,31 @@ extern "C" { (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) { try { - std::vector vecLI = JArrayToVector(env, voxelIndex); + jint *input = env->GetIntArrayElements(voxelIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLI); + IntVector2 vec2(input[0], input[1]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer2D(handle)->VoxelIndexToDataIndex(vec2); } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLI); + IntVector3 vec3(input[0], input[1], input[2]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer3D(handle)->VoxelIndexToDataIndex(vec3); } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecLI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer4D(handle)->VoxelIndexToDataIndex(vec4); } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer5D(handle)->VoxelIndexToDataIndex(vec5); } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer6D(handle)->VoxelIndexToDataIndex(vec6); } } @@ -660,31 +558,31 @@ extern "C" { (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) { try { - std::vector vecLI = JArrayToVector(env, localChunkIndex); + jint *input = env->GetIntArrayElements(localChunkIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLI); + IntVector2 vec2(input[0], input[1]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer2D(handle)->LocalChunkIndexToDataIndex(vec2); } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLI); + IntVector3 vec3(input[0], input[1], input[2]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer3D(handle)->LocalChunkIndexToDataIndex(vec3); } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecLI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer4D(handle)->LocalChunkIndexToDataIndex(vec4); } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer5D(handle)->LocalChunkIndexToDataIndex(vec5); } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer6D(handle)->LocalChunkIndexToDataIndex(vec6); } } @@ -702,31 +600,31 @@ extern "C" { (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) { try { - std::vector vecVI = JArrayToVector(env, voxelIndex); + jint *input = env->GetIntArrayElements(voxelIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecVI); + IntVector2 vec2(input[0], input[1]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer2D(handle)->VoxelIndexInProcessArea(vec2); } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecVI); + IntVector3 vec3(input[0], input[1], input[2]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer3D(handle)->VoxelIndexInProcessArea(vec3); } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecVI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer4D(handle)->VoxelIndexInProcessArea(vec4); } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecVI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer5D(handle)->VoxelIndexInProcessArea(vec5); } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecVI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); + env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); return GetVolumeIndexer6D(handle)->VoxelIndexInProcessArea(vec6); } } @@ -744,31 +642,31 @@ extern "C" { (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) { try { - std::vector vecLI = JArrayToVector(env, localIndex); + jint *input = env->GetIntArrayElements(localIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLI); + IntVector2 vec2(input[0], input[1]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer2D(handle)->LocalIndexInProcessArea(vec2); } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLI); + IntVector3 vec3(input[0], input[1], input[2]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer3D(handle)->LocalIndexInProcessArea(vec3); } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecLI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer4D(handle)->LocalIndexInProcessArea(vec4); } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer5D(handle)->LocalIndexInProcessArea(vec5); } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); + env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); return GetVolumeIndexer6D(handle)->LocalIndexInProcessArea(vec6); } } @@ -786,31 +684,31 @@ extern "C" { (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) { try { - std::vector vecLCI = JArrayToVector(env, localChunkIndex); + jint *input = env->GetIntArrayElements(localChunkIndex, 0); switch (volumeDimension) { case 2: { - IntVector2 vec2; - fillIntVector2(&vec2, vecLCI); + IntVector2 vec2(input[0], input[1]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer2D(handle)->LocalChunkIndexInProcessArea(vec2); } case 3: { - IntVector3 vec3; - fillIntVector3(&vec3, vecLCI); + IntVector3 vec3(input[0], input[1], input[2]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer3D(handle)->LocalChunkIndexInProcessArea(vec3); } case 4: { - IntVector4 vec4; - fillIntVector4(&vec4, vecLCI); + IntVector4 vec4(input[0], input[1], input[2], input[3]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer4D(handle)->LocalChunkIndexInProcessArea(vec4); } case 5: { - IntVector<5> vec5; - fillIntVector5(&vec5, vecLCI); + IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer5D(handle)->LocalChunkIndexInProcessArea(vec5); } case 6: { - IntVector<6> vec6; - fillIntVector6(&vec6, vecLCI); + IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); + env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); return GetVolumeIndexer6D(handle)->LocalChunkIndexInProcessArea(vec6); } } diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index 5f7ae4b1..ac0375de 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -16,7 +16,7 @@ public class CreateVDS { Duration elapsed = Duration.between(start, end); long hrs = elapsed.toHours(); long min = elapsed.toMinutes() - (hrs * 60); - long s = (elapsed.toMillis() - (elapsed.toMinutes() * 1000)) / 1000; + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); } catch (Throwable t) { @@ -27,11 +27,21 @@ public class CreateVDS { static void process(String[] args) throws Exception { - int samplesX = 500; // time - int samplesY = 1000; // XL - int samplesZ = 1000; // IL + int samplesX = 250; // time + int samplesY = 400; // XL + int samplesZ = 400; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; + double sizeX = samplesX; + double sizeY = samplesX; + double sizeZ = samplesX; + + double distMax = distance3D(0, 0, 0, sizeX, sizeY, sizeZ); + double cycles = Math.PI * 2 * 6; + double midX = samplesX /2f; + double midY = samplesY /2f; + double midZ = samplesY /2f; + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_128; int negativeMargin = 4; int positiveMargin = 4; @@ -71,7 +81,7 @@ public class CreateVDS { //OpenVDS::InMemoryOpenOptions options; - VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/createJava_1000_1000_500_B128.vds"); + VDSFileOpenOptions options = new VDSFileOpenOptions("/media/hdd/VDS/VDS_Dome_2000_2000_1000.vds"); VdsError error; MetadataContainer metadataContainer = new MetadataContainer(); @@ -116,7 +126,14 @@ public class CreateVDS { int chunkCount = (int) pageAccessor.getChunkCount(); System.out.println("Chunk count : " + chunkCount); + long timeRead = 0L; + long timeWrite = 0L; + long timeVolIndex = 0L; + for (int i = 0; i < chunkCount; i++) { + + long time_1 = System.currentTimeMillis(); + VolumeDataPage page = pageAccessor.createPage(i); System.out.print("Page " + (i+1) + " / " + chunkCount); @@ -149,32 +166,50 @@ public class CreateVDS { int dimPitch = pitch[dimensionality - 1] * (chunkMax[dimensionality - 1] - chunkMin[dimensionality - 1]); + long time_2 = System.currentTimeMillis(); + int[] numSamples = numSamplesChunk; + int[] localChunkIndex = new int[3]; + int[] voxelPos = new int[3]; for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { - int[] localChunkIndex = new int[]{iDim0, iDim1, iDim2}; - int[] localIndex = outputIndexer.localChunkIndexToLocalIndex(localChunkIndex); - int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); - - int pos[] = new int[] { - voxelIndex[0], - voxelIndex[1], - voxelIndex[2] - }; - - float value = (float)((iDim0 + iDim1 + iDim2)%numSamples[0]) / numSamples[0]; - value = rangeMin + 2 * value; + localChunkIndex[0] = iDim0; + localChunkIndex[1] = iDim1; + localChunkIndex[2] = iDim2; + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localChunkIndex); + + for (int vp = 0 ; vp < 3 ; ++vp) { + voxelPos[vp] = voxelIndex[vp]; + } + + float value = 0f; + double dist = 0; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } + else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = (float)Math.sin((dist * cycles) / distMax); int iPos = outputIndexer.localIndexToDataIndex(localChunkIndex); output[iPos] = value; } // write buffer then release page + long time_3 = System.currentTimeMillis(); page.writeFloatBuffer(output, pitch, dimensionality); page.pageRelease(); + long time_4 = System.currentTimeMillis(); + + timeRead += (time_2 - time_1); + timeVolIndex += (time_3 - time_2); + timeWrite += (time_4 - time_3); } + displayStatistics(timeRead, timeVolIndex, timeWrite); + pageAccessor.commit(); pageAccessor.setMaxPages(0); accessManager.flushUploadQueue(); @@ -184,6 +219,30 @@ public class CreateVDS { System.out.println("VDS closed"); } + private static void displayStatistics(long timeRead, long timeVolIndex, long timeWrite) { + long totalTime = timeRead + timeVolIndex + timeWrite; + float pctRead = (timeRead * 100f) / (float)totalTime; + float pctVolIndex = (timeVolIndex * 100f) / (float)totalTime; + float pctWrite = (timeWrite * 100f) / (float)totalTime; + + System.out.println("Read took " + timeRead + "ms : " + pctRead + "%"); + System.out.println("Write took " + timeWrite + "ms : " + pctWrite + "%"); + System.out.println("Index compute took " + timeVolIndex + "ms : " + pctVolIndex + "%"); + } + + private static double distance2D(double x1, double y1, double x2, double y2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + return Math.sqrt((diffX * diffX) + (diffY * diffY)); + } + + private static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + double diffZ = z2 - z1; + return Math.sqrt((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); + } + static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { float res[] = new float[] {1f, 0f}; float noValueCmp = useNoValue ? 1f : 0f; diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index e878194a..561c7082 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -52,7 +52,7 @@ public class VolumeDataPage extends JniPointer { // Called by JniPointer.release() @Override protected synchronized void deleteHandle() { - //cpRelease(_handle); + // nothing to do. Release page is done by its own method and must be called by the main code, not the finalizer } /** diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java index 8f687cc8..451086ec 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java @@ -9,14 +9,14 @@ public abstract class VolumeIndexerBase extends JniPointer { private static native int cpGetDataBlockNumSamples(long handle, int volumeDimension, int dim); private static native int cpGetLocalChunkNumSamples(long handle, int volumeDimension, int dim); - private static native int[] cpLocalIndexToVoxelIndex(long handle, int volumeDimension, int[] localIndex); - private static native int[] cpLocalIndexToLocalChunkIndex(long handle, int volumeDimension, int[] localIndex); + private static native void cpLocalIndexToVoxelIndex(long handle, int volumeDimension, int[] localIndex, int[] voxelIndexRes); + private static native void cpLocalIndexToLocalChunkIndex(long handle, int volumeDimension, int[] localIndex, int[] localChunkIndexRes); - private static native int[] cpVoxelIndexToLocalIndex(long handle, int volumeDimension, int[] voxelIndex); - private static native int[] cpVoxelIndexToLocalChunkIndex(long handle, int volumeDimension, int[] voxelIndex); + private static native void cpVoxelIndexToLocalIndex(long handle, int volumeDimension, int[] voxelIndex, int[] localIndexRes); + private static native void cpVoxelIndexToLocalChunkIndex(long handle, int volumeDimension, int[] voxelIndex, int[] localChunkIndexRes); - private static native int[] cpLocalChunkIndexToLocalIndex(long handle, int volumeDimension, int[] voxelIndex); - private static native int[] cpLocalChunkIndexToVoxelIndex(long handle, int volumeDimension, int[] voxelIndex); + private static native void cpLocalChunkIndexToLocalIndex(long handle, int volumeDimension, int[] localChunkIndex, int[] localIndexRes); + private static native void cpLocalChunkIndexToVoxelIndex(long handle, int volumeDimension, int[] localChunkIndex, int[] voxelIndexRes); private static native int cpLocalIndexToDataIndex(long handle, int volumeDimension, int[] localIndex); private static native int cpVoxelIndexToDataIndex(long handle, int volumeDimension, int[] voxelIndex); @@ -73,7 +73,9 @@ public abstract class VolumeIndexerBase extends JniPointer { */ public int[] localIndexToVoxelIndex(int[] localIndex) { checkLocalIndexArgument(localIndex); - return cpLocalIndexToVoxelIndex(_handle, dimensionVolume, localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToVoxelIndex(_handle, dimensionVolume, localIndex, res); + return res; } /** @@ -83,7 +85,9 @@ public abstract class VolumeIndexerBase extends JniPointer { */ public int[] localIndexToLocalChunkIndex(int[] localIndex) { checkLocalIndexArgument(localIndex); - return cpLocalIndexToLocalChunkIndex(_handle, dimensionVolume, localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToLocalChunkIndex(_handle, dimensionVolume, localIndex, res); + return res; } /** @@ -93,7 +97,9 @@ public abstract class VolumeIndexerBase extends JniPointer { */ public int[] voxelIndexToLocalIndex(int[] voxelIndex) { checkLocalIndexArgument(voxelIndex); - return cpVoxelIndexToLocalIndex(_handle, dimensionVolume, voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalIndex(_handle, dimensionVolume, voxelIndex, res); + return res; } /** @@ -103,7 +109,9 @@ public abstract class VolumeIndexerBase extends JniPointer { */ public int[] voxelIndexToLocalChunkIndex(int[] voxelIndex) { checkLocalIndexArgument(voxelIndex); - return cpVoxelIndexToLocalChunkIndex(_handle, dimensionVolume, voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalChunkIndex(_handle, dimensionVolume, voxelIndex, res); + return res; } /** @@ -113,7 +121,9 @@ public abstract class VolumeIndexerBase extends JniPointer { */ public int[] localChunkIndexToLocalIndex(int[] localChunkIndex) { checkLocalIndexArgument(localChunkIndex); - return cpLocalChunkIndexToLocalIndex(_handle, dimensionVolume, localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToLocalIndex(_handle, dimensionVolume, localChunkIndex, res); + return res; } /** @@ -123,7 +133,9 @@ public abstract class VolumeIndexerBase extends JniPointer { */ public int[] localChunkIndexToVoxelIndex(int[] localChunkIndex) { checkLocalIndexArgument(localChunkIndex); - return cpLocalChunkIndexToVoxelIndex(_handle, dimensionVolume, localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToVoxelIndex(_handle, dimensionVolume, localChunkIndex, res); + return res; } /** diff --git a/java/java/test/org/opengroup/openvds/PageAccessorTest.java b/java/java/test/org/opengroup/openvds/PageAccessorTest.java index 609bff62..88faa992 100644 --- a/java/java/test/org/opengroup/openvds/PageAccessorTest.java +++ b/java/java/test/org/opengroup/openvds/PageAccessorTest.java @@ -8,7 +8,6 @@ import org.testng.annotations.Test; import java.io.File; -import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; public class PageAccessorTest { @@ -26,7 +25,7 @@ public class PageAccessorTest { @BeforeClass public void init() { - vds = new MemoryVdsGenerator(300, 300, 100, VolumeDataChannelDescriptor.Format.FORMAT_R32); + vds = new MemoryVdsGenerator(200, 300, 300, VolumeDataChannelDescriptor.Format.FORMAT_R32); url = "inmemory://create_test"; VolumeDataLayout volumeDataLayout = vds.getLayout(); @@ -76,7 +75,7 @@ public class PageAccessorTest { fileVolIndex.delete(); } - String fileCopyPath = tempDir + File.separator + TEMP_FILE_NAME_VOL_INDEX; + String fileCopyPath = tempDir + File.separator + TEMP_FILE_NAME_COPY; File fileCopy = new File(fileCopyPath); if (fileCopy.exists()) { fileCopy.delete(); @@ -153,7 +152,8 @@ public class PageAccessorTest { // copy file int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; - for (long chunk = 0 ; chunk < pageAccessorInput.getChunkCount() ; ++chunk) { + long chunkCount = pageAccessorInput.getChunkCount(); + for (long chunk = 0 ; chunk < chunkCount ; ++chunk) { VolumeDataPage inputPage = pageAccessorInput.readPage(chunk); VolumeDataPage page = pageAccessor.createPage(chunk); float[] data = inputPage.readFloatBuffer(pitch); @@ -212,7 +212,8 @@ public class PageAccessorTest { // compares block data int[] pitchInput = new int[VolumeDataLayout.Dimensionality_Max]; int[] pitchOutput = new int[VolumeDataLayout.Dimensionality_Max]; - for (long chunk = 0 ; chunk < pageAccessorInput.getChunkCount() ; ++chunk) { + long chunkCount = pageAccessorInput.getChunkCount(); + for (long chunk = 0 ; chunk < chunkCount ; ++chunk) { VolumeDataPage inputPage = pageAccessorInput.readPage(chunk); VolumeDataPage page = pageAccessor.readPage(chunk); float[] dataIn = inputPage.readFloatBuffer(pitchInput); -- GitLab From 7d3ef4fd1b9520a97ba6c076980f9c7a9e528f0b Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Tue, 20 Apr 2021 17:58:14 +0200 Subject: [PATCH 017/194] VolumeDataPage : cast in VolumeDataPageImpl to get info about buffer allocated size Demos : create LOD volume --- java/cpp/src/VolumeDataPage.cpp | 78 +++-- java/cpp/src/VolumeDataPageAccessor.cpp | 47 +++ java/java/demo/CreateVDS.java | 18 +- java/java/demo/CreateVDSWithLOD.java | 287 ++++++++++++++++++ .../org/opengroup/openvds/VolumeDataPage.java | 75 ++--- .../openvds/VolumeDataPageAccessor.java | 31 +- .../opengroup/openvds/PageAccessorTest.java | 3 +- tools/ScratchVDSFileCreate/VDSFileCreate.cpp | 164 +++++++++- 8 files changed, 618 insertions(+), 85 deletions(-) create mode 100644 java/java/demo/CreateVDSWithLOD.java diff --git a/java/cpp/src/VolumeDataPage.cpp b/java/cpp/src/VolumeDataPage.cpp index d01517b8..72de3682 100644 --- a/java/cpp/src/VolumeDataPage.cpp +++ b/java/cpp/src/VolumeDataPage.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #ifdef __cplusplus extern "C" { @@ -28,6 +28,16 @@ extern "C" { return (OpenVDS::VolumeDataPage*) CheckHandle( handle ); } + inline int GetBufferAllocatedSize(OpenVDS::VolumeDataPage* page) { + OpenVDS::VolumeDataPageImpl* pageImpl = (OpenVDS::VolumeDataPageImpl*)page; + const OpenVDS::DataBlock block = pageImpl->GetDataBlock(); + int nbElem = 1; + for (int i = 0 ; i < OpenVDS::DataBlock::Dimensionality::Dimensionality_Max ; i++) { + nbElem *= block.AllocatedSize[i]; + } + return nbElem; + } + /* * Class: org_opengroup_openvds_VolumeDataPage * Method: cpRelease @@ -84,20 +94,23 @@ extern "C" { * Signature: (J[I)[B */ JNIEXPORT jbyteArray JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetByteBuffer - (JNIEnv * env, jclass, jlong handle, jintArray pitchParam) + (JNIEnv * env, jclass, jlong handle, jintArray pitchParam, jint lod) { try { int pitch[OpenVDS::Dimensionality_Max]; - int cMin[OpenVDS::Dimensionality_Max]; - int cMax[OpenVDS::Dimensionality_Max]; - GetVolumePage(handle)->GetMinMax(cMin, cMax); - - int chunk_size_y = cMax[2] - cMin[2]; +// int cMin[OpenVDS::Dimensionality_Max]; +// int cMax[OpenVDS::Dimensionality_Max]; + OpenVDS::VolumeDataPage* page = GetVolumePage(handle); +// page->GetMinMax(cMin, cMax); - const char* readData = reinterpret_cast(GetVolumePage(handle)->GetBuffer(pitch)); + const char* readData = static_cast(page->GetBuffer(pitch)); env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); - - int nbElem = chunk_size_y * pitch[2]; + int nbElem = GetBufferAllocatedSize(page); +// int chunk_size_MaxDim = cMax[maxDim] - cMin[maxDim]; +// int nbElem = chunk_size_MaxDim * pitch[maxDim]; +// for (int i = 0 ; i < lod ; ++i) { +// nbElem = nbElem / 2; +// } return NewJByteArray(env, readData, nbElem); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -118,7 +131,6 @@ extern "C" { int valueSize = env->GetArrayLength(values); jbyte *src = env->GetByteArrayElements(values, 0); std::memcpy(pageBuffer, src, valueSize * sizeof (char)); - // needed or not? env->ReleaseByteArrayElements(values, src, 0); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -130,20 +142,23 @@ extern "C" { * Signature: (J[I)[F */ JNIEXPORT jfloatArray JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetFloatBuffer - (JNIEnv * env, jclass, jlong handle, jintArray pitchParam) + (JNIEnv * env, jclass, jlong handle, jintArray pitchParam, jint lod) { try { int pitch[OpenVDS::Dimensionality_Max]; - int cMin[OpenVDS::Dimensionality_Max]; - int cMax[OpenVDS::Dimensionality_Max]; - GetVolumePage(handle)->GetMinMax(cMin, cMax); - - int chunk_size_y = cMax[2] - cMin[2]; +// int cMin[OpenVDS::Dimensionality_Max]; +// int cMax[OpenVDS::Dimensionality_Max]; + OpenVDS::VolumeDataPage* page = GetVolumePage(handle); +// page->GetMinMax(cMin, cMax); - const float* readData = static_cast(GetVolumePage(handle)->GetBuffer(pitch)); + const float* readData = static_cast(page->GetBuffer(pitch)); env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); - - int nbElem = chunk_size_y * pitch[2]; + int nbElem = GetBufferAllocatedSize(page); +// int chunk_size_MaxDim = cMax[maxDim] - cMin[maxDim]; +// int nbElem = chunk_size_MaxDim * pitch[maxDim]; +// for (int i = 0 ; i < lod ; ++i) { +// nbElem = nbElem / 2; +// } return NewJFloatArray(env, readData, nbElem); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -165,7 +180,6 @@ extern "C" { int valueSize = env->GetArrayLength(values); jfloat *src = env->GetFloatArrayElements(values, 0); std::memcpy(pageBuffer, src, valueSize * sizeof (float)); - // needed or not? env->ReleaseFloatArrayElements(values, src, 0); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -177,20 +191,23 @@ extern "C" { * Signature: (J[I)[D */ JNIEXPORT jdoubleArray JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetDoubleBuffer - (JNIEnv * env, jclass, jlong handle, jintArray pitchParam) + (JNIEnv * env, jclass, jlong handle, jintArray pitchParam, jint lod) { try { int pitch[OpenVDS::Dimensionality_Max]; - int cMin[OpenVDS::Dimensionality_Max]; - int cMax[OpenVDS::Dimensionality_Max]; - GetVolumePage(handle)->GetMinMax(cMin, cMax); +// int cMin[OpenVDS::Dimensionality_Max]; +// int cMax[OpenVDS::Dimensionality_Max]; + OpenVDS::VolumeDataPage* page = GetVolumePage(handle); +// page->GetMinMax(cMin, cMax); - int chunk_size_j = cMax[2] - cMin[2]; - - const double* readData = reinterpret_cast(GetVolumePage(handle)->GetBuffer(pitch)); + const double* readData = static_cast(page->GetBuffer(pitch)); env->SetIntArrayRegion(pitchParam, 0, OpenVDS::Dimensionality_Max, pitch); - - int nbElem = chunk_size_j * pitch[2]; + int nbElem = GetBufferAllocatedSize(page); +// int chunk_size_MaxDim = cMax[maxDim] - cMin[maxDim]; +// int nbElem = chunk_size_MaxDim * pitch[maxDim]; +// for (int i = 0 ; i < lod ; ++i) { +// nbElem = nbElem / 2; +// } return NewJDoubleArray(env, readData, nbElem); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -212,7 +229,6 @@ extern "C" { int valueSize = env->GetArrayLength(values); jdouble *src = env->GetDoubleArrayElements(values, 0); std::memcpy(pageBuffer, src, valueSize * sizeof (double)); - // needed or not? env->ReleaseDoubleArrayElements(values, src, 0); } CATCH_EXCEPTIONS_FOR_JAVA; diff --git a/java/cpp/src/VolumeDataPageAccessor.cpp b/java/cpp/src/VolumeDataPageAccessor.cpp index feca4cb1..5292f89b 100644 --- a/java/cpp/src/VolumeDataPageAccessor.cpp +++ b/java/cpp/src/VolumeDataPageAccessor.cpp @@ -44,6 +44,53 @@ extern "C" { return 0; } + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpGetLOD + * Signature: (J)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetLOD + (JNIEnv * env, jclass, jlong handle) + { + try { + return GetPageAccessor( handle )->GetLOD(); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpGetChannelIndex + * Signature: (J)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetChannelIndex + (JNIEnv * env, jclass, jlong handle) + { + try { + return GetPageAccessor( handle )->GetChannelIndex(); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpGetNumSamples + * Signature: (J)[I + */ + JNIEXPORT jintArray JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetNumSamples + (JNIEnv * env, jclass, jlong handle) + { + try { + int dims[OpenVDS::Dimensionality_Max]; + GetPageAccessor( handle )->GetNumSamples(dims); + return NewJIntArray(env, dims, OpenVDS::Dimensionality_Max); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return NULL; + } + /* * Class: org_opengroup_openvds_VolumeDataPageAccessor diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index ac0375de..4d4a07cc 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -27,9 +27,9 @@ public class CreateVDS { static void process(String[] args) throws Exception { - int samplesX = 250; // time - int samplesY = 400; // XL - int samplesZ = 400; // IL + int samplesX = 500; // time + int samplesY = 800; // XL + int samplesZ = 800; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; double sizeX = samplesX; @@ -38,11 +38,11 @@ public class CreateVDS { double distMax = distance3D(0, 0, 0, sizeX, sizeY, sizeZ); double cycles = Math.PI * 2 * 6; - double midX = samplesX /2f; - double midY = samplesY /2f; - double midZ = samplesY /2f; + double midX = samplesX / 2f; + double midY = samplesY / 2f; + double midZ = samplesY / 2f; - VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_128; + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_64; int negativeMargin = 4; int positiveMargin = 4; int brickSize2DMultiplier = 4; @@ -81,7 +81,7 @@ public class CreateVDS { //OpenVDS::InMemoryOpenOptions options; - VDSFileOpenOptions options = new VDSFileOpenOptions("/media/hdd/VDS/VDS_Dome_2000_2000_1000.vds"); + VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testCreate.vds"); VdsError error; MetadataContainer metadataContainer = new MetadataContainer(); @@ -199,7 +199,7 @@ public class CreateVDS { // write buffer then release page long time_3 = System.currentTimeMillis(); - page.writeFloatBuffer(output, pitch, dimensionality); + page.writeFloatBuffer(output, pitch); page.pageRelease(); long time_4 = System.currentTimeMillis(); diff --git a/java/java/demo/CreateVDSWithLOD.java b/java/java/demo/CreateVDSWithLOD.java new file mode 100644 index 00000000..e50be8fd --- /dev/null +++ b/java/java/demo/CreateVDSWithLOD.java @@ -0,0 +1,287 @@ +import org.opengroup.openvds.*; + +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.DoubleSummaryStatistics; +import java.util.List; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; + +public class CreateVDSWithLOD { + + public static void main(String[] args) { + try { + Instant start = Instant.now(); + process(args); + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } + catch (Throwable t) { + System.out.println(); + t.printStackTrace(); + } + } + + static void process(String[] args) throws Exception { + + int samplesX = 1000; // time + int samplesY = 2000; // XL + int samplesZ = 2000; // IL + VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; + + double sizeX = samplesX; + double sizeY = samplesY; + double sizeZ = samplesZ; + + double distMax = distance3D(0, 0, 0, sizeX, sizeY, sizeZ); + double cycles = Math.PI * 2 * 20; + double midX = samplesX / 2f; + double midY = samplesY / 2f; + double midZ = samplesZ / 2f; + + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_128; + int negativeMargin = 4; + int positiveMargin = 4; + int brickSize2DMultiplier = 4; + VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.LOD_LEVELS_3; + //VolumeDataLayoutDescriptor.Options layoutOptions = VolumeDataLayoutDescriptor.Options.NONE; + VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, false,false,0); + + List axisDescriptors = new ArrayList<>(); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "ms", 0.0f,4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1000f, 1000f + samplesY - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); + + List channelDescriptors = new ArrayList<>(); + + float rangeMin = -1f; + float rangeMax = 1f; + float[] scaleOffset = getScaleOffsetForFormat(rangeMin, rangeMax, true, format); + + VolumeDataChannelDescriptor channelDescriptor = new VolumeDataChannelDescriptor(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", + "", + rangeMin, // range min + rangeMax, // range max + VolumeDataMapping.DIRECT, // mapping + 1, // mapped value count + false, // is discrete + true, // is renderable + false, // allow lossy compression + false, // use zip for lossless compresion + true, // use no value + -999.25f, // no value + scaleOffset[0], // integer scale + scaleOffset[1]); // integer offset + channelDescriptors.add(channelDescriptor); + + + //OpenVDS::InMemoryOpenOptions options; + VDSFileOpenOptions options = new VDSFileOpenOptions("/media/hdd/VDS/VDS_LOD_Dome_2000_2000_1000.vds"); + VdsError error; + + MetadataContainer metadataContainer = new MetadataContainer(); + metadataContainer.setMetadataInt("categoryInt", "Int", 123); + metadataContainer.setMetadataIntVector2("categoryInt", "IntVector2", new int[] {45, 78}); + metadataContainer.setMetadataIntVector3("categoryInt", "IntVector3", new int[] {45, 78, 72}); + metadataContainer.setMetadataIntVector4("categoryInt", "IntVector4", new int[] {45, 78, 72, 84}); + metadataContainer.setMetadataFloat("categoryFloat", "Float", 123.f); + metadataContainer.setMetadataFloatVector2("categoryFloat", "FloatVector2", new float[] {45.5f, 78.75f}); + metadataContainer.setMetadataFloatVector3("categoryFloat", "FloatVector3", new float[] {45.5f, 78.75f, 72.75f}); + metadataContainer.setMetadataFloatVector4("categoryFloat", "FloatVector4", new float[] {45.5f, 78.75f, 72.75f, 84.1f}); + metadataContainer.setMetadataDouble("categoryDouble", "Double", 123.); + metadataContainer.setMetadataDoubleVector2("categoryDouble", "DoubleVector2", new double[] {45.5, 78.75}); + metadataContainer.setMetadataDoubleVector3("categoryDouble", "DoubleVector3", new double[] {45.5, 78.75, 72.75}); + metadataContainer.setMetadataDoubleVector4("categoryDouble", "DoubleVector4", new double[] {45.5, 78.75, 72.75, 84.1}); + metadataContainer.setMetadataString("categoryString", "String", "Test string"); + //metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); + + VdsHandle vds = OpenVDS.create(options, layoutDescriptor, + axisDescriptors.toArray(new VolumeDataAxisDescriptor[0]), + channelDescriptors.toArray(new VolumeDataChannelDescriptor[0]), metadataContainer); + + + VolumeDataLayout layout = vds.getLayout(); + //ASSERT_TRUE(layout); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + + int dimensionality = layout.getDimensionality(); + long timeRead = 0L; + long timeWrite = 0L; + long timeVolIndex = 0L; + + int lodCount = lodLevels.ordinal(); + + int[] localIndex = new int[3]; + int[] voxelPos = new int[3]; + + for (int lod = 0 ; lod <= lodCount ; ++lod) { + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + lod, // lod + channel, // channel + 1000, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + + //ASSERT_TRUE(pageAccessor); + int paLOD = pageAccessor.getLOD(); + int paCI = pageAccessor.getChannelIndex(); + int[] paNumSamples = pageAccessor.getNumSamples(); + + int chunkCount = (int) pageAccessor.getChunkCount(); + System.out.println("LOD : " + lod + " Chunk count : " + chunkCount); + + for (int i = 0; i < chunkCount; i++) { + + long time_1 = System.currentTimeMillis(); + + VolumeDataPage page = pageAccessor.createPage(i); + System.out.print("LOD : " + lod + " / Page " + (i + 1) + " / " + chunkCount); + + VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, lod, DimensionsND.DIMENSIONS_012.ordinal(), layout); + float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); + + int[] numSamplesChunk = new int[3]; + int[] numSamplesDB = new int[3]; + + for (int j = 0; j < 3; j++) { + numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); + numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); + } + System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); + System.out.print("\tDimensions DataBlok : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + + page.getMinMax(chunkMin, chunkMax); + + System.out.print("\tCoords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[2] + "/" + chunkMax[2]); + int chunkSizeY = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + + float[] output = page.readFloatBuffer(pitch); + DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); + DoubleSummaryStatistics stats = ds.summaryStatistics(); + System.out.print( " Page Buffer Size : " + output.length + " / [" + stats.getMin() + "," + stats.getMax() + "]"); + // dimension of buffer + System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); + + int dimPitch = pitch[dimensionality - 1] * (chunkMax[dimensionality - 1] - chunkMin[dimensionality - 1]); + + long time_2 = System.currentTimeMillis(); + + int[] numSamples = numSamplesChunk; + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + localIndex[0] = iDim0; + localIndex[1] = iDim1; + localIndex[2] = iDim2; + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); + for (int vp = 0; vp < 3; ++vp) { + voxelPos[vp] = voxelIndex[vp]; + } + + float value = 0f; + double dist = 0; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = (float) Math.sin((dist * cycles) / distMax); + + int iPos = outputIndexer.localIndexToDataIndex(localIndex); + output[iPos] = value; + } + + // write buffer then release page + long time_3 = System.currentTimeMillis(); + page.writeFloatBuffer(output, pitch); + page.pageRelease(); + long time_4 = System.currentTimeMillis(); + + timeRead += (time_2 - time_1); + timeVolIndex += (time_3 - time_2); + timeWrite += (time_4 - time_3); + } + + pageAccessor.commit(); + pageAccessor.setMaxPages(0); + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + } + + displayStatistics(timeRead, timeVolIndex, timeWrite); + + + + vds.close(); // equivalent to OpenVDS.close(vds); ? + System.out.println("VDS closed"); + } + + private static void displayStatistics(long timeRead, long timeVolIndex, long timeWrite) { + long totalTime = timeRead + timeVolIndex + timeWrite; + float pctRead = (timeRead * 100f) / (float)totalTime; + float pctVolIndex = (timeVolIndex * 100f) / (float)totalTime; + float pctWrite = (timeWrite * 100f) / (float)totalTime; + + System.out.println("Read took " + timeRead + "ms : " + pctRead + "%"); + System.out.println("Write took " + timeWrite + "ms : " + pctWrite + "%"); + System.out.println("Index compute took " + timeVolIndex + "ms : " + pctVolIndex + "%"); + } + + private static double distance2D(double x1, double y1, double x2, double y2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + return Math.sqrt((diffX * diffX) + (diffY * diffY)); + } + + private static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + double diffZ = z2 - z1; + return Math.sqrt((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); + } + + static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { + float res[] = new float[] {1f, 0f}; + float noValueCmp = useNoValue ? 1f : 0f; + switch (format) { + case FORMAT_U8: + res[0] = 1.f / (255.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_U16: + res[0] = 1.f / (65535.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_R32: + case FORMAT_U32: + case FORMAT_R64: + case FORMAT_U64: + case FORMAT_1BIT: + case FORMAT_ANY: + res[0] = 1.0f; + res[1] = 0.0f; + } + return res; + } + +} diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index 561c7082..19c62e60 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -25,24 +25,31 @@ public class VolumeDataPage extends JniPointer { private static native void cpGetMinMaxExcludingMargin(long handle, int[] min, int[] max); - private static native byte[] cpGetByteBuffer(long handle, int[] pitch); + private static native byte[] cpGetByteBuffer(long handle, int[] pitch, int lod); private static native void cpSetByteBuffer(long handle, byte[] buffer); - private static native float[] cpGetFloatBuffer(long handle, int[] pitch); + private static native float[] cpGetFloatBuffer(long handle, int[] pitch, int lod); private static native void cpSetFloatBuffer(long handle, float[] buffer); - private static native double[] cpGetDoubleBuffer(long handle, int[] pitch); + private static native double[] cpGetDoubleBuffer(long handle, int[] pitch, int lod); private static native void cpSetDoubleBuffer(long handle, double[] buffer); - public VolumeDataPage(long handle) { + private final int dimensionality; + private final int lod; + + public VolumeDataPage(long handle, int dimensionality, int lod) { super(handle, true); + this.dimensionality = dimensionality; + this.lod = lod; } - public VolumeDataPage(long handle, boolean ownHandle) { + public VolumeDataPage(long handle, int dimensionality, int lod, boolean ownHandle) { super(handle, ownHandle); + this.dimensionality = dimensionality; + this.lod = lod; } public void pageRelease() { @@ -84,17 +91,16 @@ public class VolumeDataPage extends JniPointer { */ public byte[] readByteBuffer(int[] pitch) { checkDimParamArray(pitch, "Wrong pitch array parameter size, expected "); - return cpGetByteBuffer(_handle, pitch); + return cpGetByteBuffer(_handle, pitch, lod); } /** * Set byte array int page * @param buffer values to set. Size must match page sample size * @param pitch chunk pitch (got by a read) - * @param dimensionality volume dimensionality */ - public void writeByteBuffer(byte[] buffer, int[] pitch, int dimensionality) { - checkBufferSize(buffer, pitch, dimensionality); + public void writeByteBuffer(byte[] buffer, int[] pitch) { + //checkBufferSize(buffer, pitch, dimensionality, lod); cpSetByteBuffer(_handle, buffer); } @@ -105,17 +111,16 @@ public class VolumeDataPage extends JniPointer { */ public float[] readFloatBuffer(int[] pitch) { checkDimParamArray(pitch, "Wrong pitch array parameter size, expected "); - return cpGetFloatBuffer(_handle, pitch); + return cpGetFloatBuffer(_handle, pitch, lod); } /** * Set float array int page * @param buffer values to set. Size must match page sample size * @param pitch chunk pitch (got by a read) - * @param dimensionality volume dimensionality */ - public void writeFloatBuffer(float[] buffer, int[] pitch, int dimensionality) { - checkBufferSize(buffer, pitch, dimensionality); + public void writeFloatBuffer(float[] buffer, int[] pitch) { + //checkBufferSize(buffer, pitch, dimensionality, lod); cpSetFloatBuffer(_handle, buffer); } @@ -126,17 +131,16 @@ public class VolumeDataPage extends JniPointer { */ public double[] readDoubleBuffer(int[] pitch) { checkDimParamArray(pitch, "Wrong pitch array parameter size, expected "); - return cpGetDoubleBuffer(_handle, pitch); + return cpGetDoubleBuffer(_handle, pitch, lod); } /** * Set double array int page * @param buffer values to set. Size must match page sample size * @param pitch chunk pitch (got by a read) - * @param dimensionality volume dimensionality */ - public void writeDoubleBuffer(double[] buffer, int[] pitch, int dimensionality) { - checkBufferSize(buffer, pitch, dimensionality); + public void writeDoubleBuffer(double[] buffer, int[] pitch) { + //checkBufferSize(buffer, pitch, dimensionality, lod); cpSetDoubleBuffer(_handle, buffer); } @@ -147,33 +151,36 @@ public class VolumeDataPage extends JniPointer { return getElementCount(chunkMin, chunkMax); } - private void checkBufferSize(byte[] buffer, int[] pitch, int dim) { - int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; - getMinMax(chunkMin, chunkMax); - int nbElem = (chunkMax[dim - 1] - chunkMin[dim - 1]) * pitch[dim - 1]; - if (buffer == null || buffer.length != nbElem) { - throw new IllegalArgumentException("Wrong buffer size, expected " + nbElem + "(dim2 * pitch[2]), got " + (buffer == null ? "null" : buffer.length)); + private void checkBufferSize(byte[] buffer, int[] pitch, int dim, int lod) { + if (buffer == null) { + throw new IllegalArgumentException("Wrong buffer size, got NULL"); } + checkBufferSize(buffer.length, pitch, dimensionality, lod); } - private void checkBufferSize(float[] buffer, int[] pitch, int dim) { - int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; - getMinMax(chunkMin, chunkMax); - int nbElem = (chunkMax[dim - 1] - chunkMin[dim - 1]) * pitch[dim - 1]; - if (buffer == null || buffer.length != nbElem) { - throw new IllegalArgumentException("Wrong buffer size, expected " + nbElem + "(dim2 * pitch[2]), got " + (buffer == null ? "null" : buffer.length)); + private void checkBufferSize(float[] buffer, int[] pitch, int dim, int lod) { + if (buffer == null) { + throw new IllegalArgumentException("Wrong buffer size, got NULL"); + } + checkBufferSize(buffer.length, pitch, dimensionality, lod); + } + + private void checkBufferSize(double[] buffer, int[] pitch, int dim, int lod) { + if (buffer == null) { + throw new IllegalArgumentException("Wrong buffer size, got NULL"); } + checkBufferSize(buffer.length, pitch, dimensionality, lod); } - private void checkBufferSize(double[] buffer, int[] pitch, int dim) { + private void checkBufferSize(int sizeInputBuffer, int[] pitch, int dim, int lod) { int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + int div = (int)Math.pow(2, lod); getMinMax(chunkMin, chunkMax); int nbElem = (chunkMax[dim - 1] - chunkMin[dim - 1]) * pitch[dim - 1]; - if (buffer == null || buffer.length != nbElem) { - throw new IllegalArgumentException("Wrong buffer size, expected " + nbElem + "(dim2 * pitch[2]), got " + (buffer == null ? "null" : buffer.length)); + nbElem /= div; + if (sizeInputBuffer != nbElem) { + throw new IllegalArgumentException("Wrong buffer size, expected " + nbElem + "(dim2 * pitch[2]), got " + sizeInputBuffer); } } diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java index 9e885715..64ea7827 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java @@ -20,6 +20,9 @@ package org.opengroup.openvds; public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { private static native long cpGetLayout( long handle ); + private static native int cpGetLOD( long handle ); + private static native int cpGetChannelIndex(long handle); + private static native int[] cpGetNumSamples(long handle); private static native long cpGetChunkCount( long handle ); private static native void cpGetChunkMinMax( long handle, int chunk, int[] chunkMin, int[] chunkMax); private static native void cpGetChunkMinMaxExcludingMargin( long handle, int chunk, int[] chunkMin, int[] chunkMax); @@ -28,7 +31,6 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { private static native void cpCommit(long handle); private static native void cpSetMaxPage(long handle, int maxPage); - VolumeDataPageAccessor(long handle) { super(handle); } @@ -41,6 +43,29 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { return new VolumeDataLayout( cpGetLayout(_handle) ); } + /** + * @return the LOD value for this page accessor + */ + public int getLOD() { + return cpGetLOD(_handle); + } + + /** + * @return the channel index for this page accessor + */ + public int getChannelIndex() { + return cpGetChannelIndex(_handle); + } + + /** + * Get the num samples for this page accessor on each dimension + * @return an array of size Dimensionality_Max (or null if error) + */ + public int[] getNumSamples() { + return cpGetNumSamples(_handle); + } + + /** * @return the chunk count */ @@ -84,7 +109,7 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { if (chunkIndex < 0 || chunkIndex >= getChunkCount()) { throw new IllegalArgumentException("VolumeDataPageAccessor::createPage : wrong chunk index"); } - return new VolumeDataPage(cpCreatePage(_handle, chunkIndex)); + return new VolumeDataPage(cpCreatePage(_handle, chunkIndex), getLayout().getDimensionality(), getLOD()); } /** @@ -97,7 +122,7 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { if (chunkIndex < 0 || chunkIndex >= getChunkCount()) { throw new IllegalArgumentException("VolumeDataPageAccessor::readPage : wrong chunk index"); } - return new VolumeDataPage(cpReadPage(_handle, chunkIndex)); + return new VolumeDataPage(cpReadPage(_handle, chunkIndex), getLayout().getDimensionality(), getLOD()); } /** diff --git a/java/java/test/org/opengroup/openvds/PageAccessorTest.java b/java/java/test/org/opengroup/openvds/PageAccessorTest.java index 88faa992..328ffedc 100644 --- a/java/java/test/org/opengroup/openvds/PageAccessorTest.java +++ b/java/java/test/org/opengroup/openvds/PageAccessorTest.java @@ -148,7 +148,6 @@ public class PageAccessorTest { channel, // channel 20, // max pages VolumeDataAccessManager.AccessMode.ReadOnly.getCode()); // access mode - int dimensionality = layout.getDimensionality(); // copy file int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; @@ -157,7 +156,7 @@ public class PageAccessorTest { VolumeDataPage inputPage = pageAccessorInput.readPage(chunk); VolumeDataPage page = pageAccessor.createPage(chunk); float[] data = inputPage.readFloatBuffer(pitch); - page.writeFloatBuffer(data, pitch, dimensionality); + page.writeFloatBuffer(data, pitch); inputPage.pageRelease(); page.pageRelease(); diff --git a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp index 50896669..1524d5d3 100644 --- a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp +++ b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp @@ -65,8 +65,14 @@ int64_t GetTotalSystemMemory() #else #include +#include +void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ); +void createLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels); +double distance2D(double x1, double y1, double x2, double y2); +double distance3D(double x1, double y1, double x2, double y2, double x3, double y3); + int64_t GetTotalSystemMemory() { long pages = sysconf(_SC_PHYS_PAGES); long page_size = sysconf(_SC_PAGE_SIZE); @@ -100,9 +106,17 @@ getScaleOffsetForFormat(float min, float max, bool novalue, OpenVDS::VolumeDataC int main(int argc, char *argv[]) { - int32_t samplesX = 200; - int32_t samplesY = 300; - int32_t samplesZ = 300; + int32_t samplesX = 250; + int32_t samplesY = 400; + int32_t samplesZ = 400; + + //createNoLODVDS(samplesX, samplesY, samplesZ); + createLODVDS(samplesX, samplesY, samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels_2); + + return EXIT_SUCCESS; +} + +void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ) { OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_64; @@ -128,7 +142,7 @@ main(int argc, char *argv[]) { channelDescriptors.emplace_back(format, OpenVDS::VolumeDataChannelDescriptor::Components_1, AMPLITUDE_ATTRIBUTE_NAME, "", rangeMin, rangeMax, OpenVDS::VolumeDataMapping::Direct, 1, - OpenVDS::VolumeDataChannelDescriptor::Default, 0.f, intScale, intOffset); + OpenVDS::VolumeDataChannelDescriptor::Default, -999.25f, intScale, intOffset); //OpenVDS::InMemoryOpenOptions options; OpenVDS::VDSFileOpenOptions options("/tmp/createCPP_bis.vds"); @@ -162,7 +176,7 @@ main(int argc, char *argv[]) { //ASSERT_TRUE(accessManager); int32_t channel = 0; - OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, channel, 0, 1000, OpenVDS::VolumeDataAccessManager::AccessMode_Create); + OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, 0, channel, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); //ASSERT_TRUE(pageAccessor); int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); @@ -203,6 +217,144 @@ main(int argc, char *argv[]) { accessManager->DestroyVolumeDataPageAccessor(pageAccessor); OpenVDS::Close(vds); +} - return EXIT_SUCCESS; +void createLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels lodLevel) { + + double distMax = distance3D(0, 0, 0, samplesX, samplesY, samplesZ); + double cycles = M_PI * 2 * 6; + double midX = samplesX / 2.f; + double midY = samplesY / 2.f; + double midZ = samplesZ / 2.f; + + OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; + + auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_64; + int negativeMargin = 4; + int positiveMargin = 4; + int brickSize2DMultiplier = 4; + auto lodLevels = lodLevel; + int lodLevelCount = lodLevel; + auto layoutOptions = OpenVDS::VolumeDataLayoutDescriptor::Options_None; + OpenVDS::VolumeDataLayoutDescriptor layoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, layoutOptions); + + std::vector axisDescriptors; + axisDescriptors.emplace_back(samplesX, "Sample", "s", 0.0f,4.f); + axisDescriptors.emplace_back(samplesY, "Crossline", "",1932.f, 1932.f + samplesY - 1.f); + axisDescriptors.emplace_back(samplesZ, "Inline", "", 9985.f, 9985.f + samplesZ - 1.f); + + std::vector channelDescriptors; + float rangeMin = -1.f; + float rangeMax = 1.f; + float intScale; + float intOffset; + getScaleOffsetForFormat(rangeMin, rangeMax, true, format, intScale, intOffset); + channelDescriptors.emplace_back(format, OpenVDS::VolumeDataChannelDescriptor::Components_1, + AMPLITUDE_ATTRIBUTE_NAME, "", rangeMin, rangeMax, + OpenVDS::VolumeDataMapping::Direct, 1, + OpenVDS::VolumeDataChannelDescriptor::Default, -999.25f, intScale, intOffset); + + //OpenVDS::InMemoryOpenOptions options; + OpenVDS::VDSFileOpenOptions options("/tmp/createCPP_LOD.vds"); + OpenVDS::Error error; + + OpenVDS::MetadataContainer metadataContainer; + metadataContainer.SetMetadataInt("categoryInt", "Int", 123); + metadataContainer.SetMetadataIntVector2("categoryInt", "IntVector2", OpenVDS::IntVector2(45, 78)); + metadataContainer.SetMetadataIntVector3("categoryInt", "IntVector3", OpenVDS::IntVector3(45, 78, 72)); + metadataContainer.SetMetadataIntVector4("categoryInt", "IntVector4", OpenVDS::IntVector4(45, 78, 72, 84)); + metadataContainer.SetMetadataFloat("categoryFloat", "Float", 123.f); + metadataContainer.SetMetadataFloatVector2("categoryFloat", "FloatVector2", OpenVDS::FloatVector2(45.5f, 78.75f)); + metadataContainer.SetMetadataFloatVector3("categoryFloat", "FloatVector3", + OpenVDS::FloatVector3(45.5f, 78.75f, 72.75f)); + metadataContainer.SetMetadataFloatVector4("categoryFloat", "FloatVector4", + OpenVDS::FloatVector4(45.5f, 78.75f, 72.75f, 84.1f)); + metadataContainer.SetMetadataDouble("categoryDouble", "Double", 123.); + metadataContainer.SetMetadataDoubleVector2("categoryDouble", "DoubleVector2", OpenVDS::DoubleVector2(45.5, 78.75)); + metadataContainer.SetMetadataDoubleVector3("categoryDouble", "DoubleVector3", + OpenVDS::DoubleVector3(45.5, 78.75, 72.75)); + metadataContainer.SetMetadataDoubleVector4("categoryDouble", "DoubleVector4", + OpenVDS::DoubleVector4(45.5, 78.75, 72.75, 84.1)); + metadataContainer.SetMetadataString("categoryString", "String", std::string("Test string")); + + auto vds = OpenVDS::Create(options, layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, + error); + + OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(vds); + //ASSERT_TRUE(layout); + OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(vds); + //ASSERT_TRUE(accessManager); + + for (int lod = 0 ; lod <= lodLevelCount ; lod ++) { + int32_t channel = 0; + OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, lod, channel, 100, + OpenVDS::VolumeDataAccessManager::AccessMode_Create); + //ASSERT_TRUE(pageAccessor); + + int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); + //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); + int posMax = -1; + for (int i = 0; i < chunkCount; i++) { + OpenVDS::VolumeDataPage *page = pageAccessor->CreatePage(i); + OpenVDS::VolumeIndexer3D outputIndexer(page, 0, lod, OpenVDS::Dimensions_012, layout); + OpenVDS::IntVector<3> numSamples; + + for (int j = 0; j < 3; j++) { + numSamples[j] = outputIndexer.GetDataBlockNumSamples(j); + } + + int pitch[OpenVDS::VolumeDataLayout::Dimensionality_Max]; + int chunkMin[OpenVDS::VolumeDataLayout::Dimensionality_Max]; + int chunkMax[OpenVDS::VolumeDataLayout::Dimensionality_Max]; + + page->GetMinMax(chunkMin, chunkMax); + + void *buffer = page->GetWritableBuffer(pitch); + auto output = static_cast(buffer); + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + OpenVDS::IntVector<3> localIndex(iDim0, iDim1, iDim2); + OpenVDS::IntVector<3> voxelPos = outputIndexer.LocalIndexToVoxelIndex(localIndex); + + float value = 0.f; + double dist = 0.; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = (float) sin((dist * cycles) / distMax); + + int dataPos = outputIndexer.LocalIndexToDataIndex(localIndex); + posMax = dataPos > posMax ? dataPos : posMax; + output[dataPos] = value; + } + + page->Release(); + } + std::cout << "For LOD " << lod << " position Max is " << posMax << std::endl; + + pageAccessor->Commit(); + pageAccessor->SetMaxPages(0); + accessManager->FlushUploadQueue(); + accessManager->DestroyVolumeDataPageAccessor(pageAccessor); + } + + OpenVDS::Close(vds); +} + +double distance2D(double x1, double y1, double x2, double y2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + return sqrt((diffX * diffX) + (diffY * diffY)); +} + +double distance3D(double x1, double y1, double z1, double x2, double y2, double z2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + double diffZ = z2 - z1; + return sqrt((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); } -- GitLab From 12f7fc153bac2e238aab3f6e6d4a674a9b04aea6 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Thu, 22 Apr 2021 18:00:20 +0200 Subject: [PATCH 018/194] Refactor VolumeIndexer --- java/cpp/src/VolumeDataPage.cpp | 15 + java/cpp/src/VolumeIndexer2D.cpp | 188 ++++++ java/cpp/src/VolumeIndexer3D.cpp | 186 ++++++ java/cpp/src/VolumeIndexer4D.cpp | 184 ++++++ java/cpp/src/VolumeIndexer5D.cpp | 186 +++++- java/cpp/src/VolumeIndexer6D.cpp | 186 +++++- java/cpp/src/VolumeIndexerBase.cpp | 537 ------------------ java/java/demo/CreateVDSWithLOD.java | 8 +- .../org/opengroup/openvds/VolumeDataPage.java | 33 +- .../opengroup/openvds/VolumeIndexer2D.java | 113 ++++ .../opengroup/openvds/VolumeIndexer3D.java | 112 ++++ .../opengroup/openvds/VolumeIndexer4D.java | 112 ++++ .../opengroup/openvds/VolumeIndexer5D.java | 112 ++++ .../opengroup/openvds/VolumeIndexer6D.java | 112 ++++ .../opengroup/openvds/VolumeIndexerBase.java | 94 +-- tools/ScratchVDSFileCreate/VDSFileCreate.cpp | 23 +- 16 files changed, 1558 insertions(+), 643 deletions(-) diff --git a/java/cpp/src/VolumeDataPage.cpp b/java/cpp/src/VolumeDataPage.cpp index 72de3682..bf9efebe 100644 --- a/java/cpp/src/VolumeDataPage.cpp +++ b/java/cpp/src/VolumeDataPage.cpp @@ -88,6 +88,21 @@ extern "C" { CATCH_EXCEPTIONS_FOR_JAVA; } + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpGetAllocatedSize + * Signature: (J)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetAllocatedSize + (JNIEnv * env, jclass, jlong handle) + { + try { + return GetBufferAllocatedSize(GetVolumePage(handle)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + /* * Class: org_opengroup_openvds_VolumeDataPage * Method: cpGetByteBuffer diff --git a/java/cpp/src/VolumeIndexer2D.cpp b/java/cpp/src/VolumeIndexer2D.cpp index d01edd72..507af7c1 100644 --- a/java/cpp/src/VolumeIndexer2D.cpp +++ b/java/cpp/src/VolumeIndexer2D.cpp @@ -27,6 +27,10 @@ using namespace OpenVDS; extern "C" { #endif + inline VolumeIndexer2D * GetVolumeIndexer2D( jlong handle ) { + return (VolumeIndexer2D*)CheckHandle( handle ); + } + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); } @@ -53,6 +57,190 @@ extern "C" { return 0; } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpLocalIndexToVoxelIndex + * Signature: (JI[III)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpLocalIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j) + { + try { + IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToVoxelIndex(IntVector2(i, j)); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpLocalIndexToLocalChunkIndex + * Signature: (J[III)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpLocalIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j) + { + try { + IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToLocalChunkIndex(IntVector2(i, j)); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpVoxelIndexToLocalIndex + * Signature: (J[III)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpVoxelIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j) + { + try { + IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalIndex(IntVector2(i, j)); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpVoxelIndexToLocalChunkIndex + * Signature: (J[III)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpVoxelIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j) + { + try { + IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalChunkIndex(IntVector2(i, j)); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpLocalChunkIndexToLocalIndex + * Signature: (J[III)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpLocalChunkIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j) + { + try { + IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToLocalIndex(IntVector2(i, j)); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpLocalChunkIndexToVoxelIndex + * Signature: (J[III)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpLocalChunkIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j) + { + try { + IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToVoxelIndex(IntVector2(i, j)); + env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpLocalIndexToDataIndex + * Signature: (JII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpLocalIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j) + { + try { + return GetVolumeIndexer2D(handle)->LocalIndexToDataIndex(IntVector2(i, j)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpVoxelIndexToDataIndex + * Signature: (JII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpVoxelIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j) + { + try { + return GetVolumeIndexer2D(handle)->VoxelIndexToDataIndex(IntVector2(i, j)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpLocalChunkIndexToDataIndex + * Signature: (JII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpLocalChunkIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j) + { + try { + return GetVolumeIndexer2D(handle)->LocalChunkIndexToDataIndex(IntVector2(i, j)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpVoxelIndexInProcessArea + * Signature: (JII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpVoxelIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j) + { + try { + return GetVolumeIndexer2D(handle)->VoxelIndexInProcessArea(IntVector2(i, j)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpLocalIndexInProcessArea + * Signature: (JII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpLocalIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j) + { + try { + return GetVolumeIndexer2D(handle)->LocalIndexInProcessArea(IntVector2(i, j)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer2D + * Method: cpLocalChunkIndexInProcessArea + * Signature: (JII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer2D_cpLocalChunkIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j) + { + try { + return GetVolumeIndexer2D(handle)->LocalChunkIndexInProcessArea(IntVector2(i, j)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeIndexer3D.cpp b/java/cpp/src/VolumeIndexer3D.cpp index 5c96da3f..d9e74a9b 100644 --- a/java/cpp/src/VolumeIndexer3D.cpp +++ b/java/cpp/src/VolumeIndexer3D.cpp @@ -27,6 +27,10 @@ using namespace OpenVDS; extern "C" { #endif + inline VolumeIndexer3D * GetVolumeIndexer3D( jlong handle ) { + return (VolumeIndexer3D*)CheckHandle( handle ); + } + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); } @@ -53,6 +57,188 @@ extern "C" { return 0; } + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpLocalIndexToVoxelIndex + * Signature: (JI[IIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpLocalIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j , jint k) + { + try { + IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToVoxelIndex(IntVector3(i, j, k)); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpLocalIndexToLocalChunkIndex + * Signature: (J[IIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpLocalIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k) + { + try { + IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToLocalChunkIndex(IntVector3(i, j, k)); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpVoxelIndexToLocalIndex + * Signature: (J[IIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpVoxelIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k) + { + try { + IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalIndex(IntVector3(i, j, k)); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpVoxelIndexToLocalChunkIndex + * Signature: (J[IIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpVoxelIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k) + { + try { + IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalChunkIndex(IntVector3(i, j, k)); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpLocalChunkIndexToLocalIndex + * Signature: (J[IIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpLocalChunkIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k) + { + try { + IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToLocalIndex(IntVector3(i, j, k)); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpLocalChunkIndexToVoxelIndex + * Signature: (J[IIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpLocalChunkIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k) + { + try { + IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToVoxelIndex(IntVector3(i, j, k)); + env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpLocalIndexToDataIndex + * Signature: (JIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpLocalIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k) + { + try { + return GetVolumeIndexer3D(handle)->LocalIndexToDataIndex(IntVector3(i, j, k)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpVoxelIndexToDataIndex + * Signature: (JIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpVoxelIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k) + { + try { + return GetVolumeIndexer3D(handle)->VoxelIndexToDataIndex(IntVector3(i, j, k)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpLocalChunkIndexToDataIndex + * Signature: (JIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpLocalChunkIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k) + { + try { + return GetVolumeIndexer3D(handle)->LocalChunkIndexToDataIndex(IntVector3(i, j, k)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpVoxelIndexInProcessArea + * Signature: (JIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpVoxelIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k) + { + try { + return GetVolumeIndexer3D(handle)->VoxelIndexInProcessArea(IntVector3(i, j, k)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpLocalIndexInProcessArea + * Signature: (JIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpLocalIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k) + { + try { + return GetVolumeIndexer3D(handle)->LocalIndexInProcessArea(IntVector3(i, j, k)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer3D + * Method: cpLocalChunkIndexInProcessArea + * Signature: (JIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer3D_cpLocalChunkIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k) + { + try { + return GetVolumeIndexer3D(handle)->LocalChunkIndexInProcessArea(IntVector3(i, j, k)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeIndexer4D.cpp b/java/cpp/src/VolumeIndexer4D.cpp index f9ffa62f..912aded9 100644 --- a/java/cpp/src/VolumeIndexer4D.cpp +++ b/java/cpp/src/VolumeIndexer4D.cpp @@ -27,6 +27,10 @@ using namespace OpenVDS; extern "C" { #endif + inline VolumeIndexer4D * GetVolumeIndexer4D( jlong handle ) { + return (VolumeIndexer4D*)CheckHandle( handle ); + } + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); } @@ -53,6 +57,186 @@ extern "C" { return 0; } + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpLocalIndexToVoxelIndex + * Signature: (J[IIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpLocalIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l) + { + try { + IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToVoxelIndex(IntVector4(i, j, k, l)); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpLocalIndexToLocalChunkIndex + * Signature: (J[IIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpLocalIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l) + { + try { + IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToLocalChunkIndex(IntVector4(i, j, k, l)); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpVoxelIndexToLocalIndex + * Signature: (J[IIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpVoxelIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l) + { + try { + IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalIndex(IntVector4(i, j, k, l)); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpVoxelIndexToLocalChunkIndex + * Signature: (J[IIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpVoxelIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l) + { + try { + IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalChunkIndex(IntVector4(i, j, k, l)); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpLocalChunkIndexToLocalIndex + * Signature: (J[IIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpLocalChunkIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l) + { + try { + IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToLocalIndex(IntVector4(i, j, k, l)); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpLocalChunkIndexToVoxelIndex + * Signature: (J[IIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpLocalChunkIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l) + { + try { + IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToVoxelIndex(IntVector4(i, j, k, l)); + env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpLocalIndexToDataIndex + * Signature: (JIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpLocalIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l) + { + try { + return GetVolumeIndexer4D(handle)->LocalIndexToDataIndex(IntVector4(i, j, k, l)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpVoxelIndexToDataIndex + * Signature: (JIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpVoxelIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l) + { + try { + return GetVolumeIndexer4D(handle)->VoxelIndexToDataIndex(IntVector4(i, j, k, l)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpLocalChunkIndexToDataIndex + * Signature: (JIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpLocalChunkIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l) + { + try { + return GetVolumeIndexer4D(handle)->LocalChunkIndexToDataIndex(IntVector4(i, j, k, l)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpVoxelIndexInProcessArea + * Signature: (JIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpVoxelIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l) + { + try { + return GetVolumeIndexer4D(handle)->VoxelIndexInProcessArea(IntVector4(i, j, k, l)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpLocalIndexInProcessArea + * Signature: (JIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpLocalIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l) + { + try { + return GetVolumeIndexer4D(handle)->LocalIndexInProcessArea(IntVector4(i, j, k, l)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer4D + * Method: cpLocalChunkIndexInProcessArea + * Signature: (JIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer4D_cpLocalChunkIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l) + { + try { + return GetVolumeIndexer4D(handle)->LocalChunkIndexInProcessArea(IntVector4(i, j, k, l)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeIndexer5D.cpp b/java/cpp/src/VolumeIndexer5D.cpp index 34e2ea25..9dcbd762 100644 --- a/java/cpp/src/VolumeIndexer5D.cpp +++ b/java/cpp/src/VolumeIndexer5D.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include #include #include #include @@ -27,6 +27,10 @@ using namespace OpenVDS; extern "C" { #endif + inline VolumeIndexer5D * GetVolumeIndexer5D( jlong handle ) { + return (VolumeIndexer5D*)CheckHandle( handle ); + } + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); } @@ -53,6 +57,186 @@ extern "C" { return 0; } + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpLocalIndexToVoxelIndex + * Signature: (J[IIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpLocalIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m) + { + try { + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToVoxelIndex(IntVector<5>(i, j, k, l, m)); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpLocalIndexToLocalChunkIndex + * Signature: (J[IIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpLocalIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m) + { + try { + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToLocalChunkIndex(IntVector<5>(i, j, k, l, m)); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpVoxelIndexToLocalIndex + * Signature: (J[IIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpVoxelIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m) + { + try { + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToLocalChunkIndex(IntVector<5>(i, j, k, l, m)); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpVoxelIndexToLocalChunkIndex + * Signature: (J[IIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpVoxelIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m) + { + try { + IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalChunkIndex(IntVector<5>(i, j, k, l, m)); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpLocalChunkIndexToLocalIndex + * Signature: (J[IIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpLocalChunkIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m) + { + try { + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToLocalIndex(IntVector<5>(i, j, k, l, m)); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpLocalChunkIndexToVoxelIndex + * Signature: (J[IIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpLocalChunkIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m) + { + try { + IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToVoxelIndex(IntVector<5>(i, j, k, l, m)); + env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpLocalIndexToDataIndex + * Signature: (JIIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpLocalIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m) + { + try { + return GetVolumeIndexer5D(handle)->LocalIndexToDataIndex(IntVector<5>(i, j, k, l, m)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpVoxelIndexToDataIndex + * Signature: (JIIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpVoxelIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m) + { + try { + return GetVolumeIndexer5D(handle)->VoxelIndexToDataIndex(IntVector<5>(i, j, k, l, m)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpLocalChunkIndexToDataIndex + * Signature: (JIIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpLocalChunkIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m) + { + try { + return GetVolumeIndexer5D(handle)->LocalChunkIndexToDataIndex(IntVector<5>(i, j, k, l, m)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpVoxelIndexInProcessArea + * Signature: (JIIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpVoxelIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m) + { + try { + return GetVolumeIndexer5D(handle)->VoxelIndexInProcessArea(IntVector<5>(i, j, k, l, m)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpLocalIndexInProcessArea + * Signature: (JIIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpLocalIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m) + { + try { + return GetVolumeIndexer5D(handle)->LocalIndexInProcessArea(IntVector<5>(i, j, k, l, m)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer5D + * Method: cpLocalChunkIndexInProcessArea + * Signature: (JIIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer5D_cpLocalChunkIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m) + { + try { + return GetVolumeIndexer5D(handle)->LocalChunkIndexInProcessArea(IntVector<5>(i, j, k, l, m)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeIndexer6D.cpp b/java/cpp/src/VolumeIndexer6D.cpp index d9952144..765c1c98 100644 --- a/java/cpp/src/VolumeIndexer6D.cpp +++ b/java/cpp/src/VolumeIndexer6D.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include #include #include #include @@ -27,6 +27,10 @@ using namespace OpenVDS; extern "C" { #endif + inline VolumeIndexer6D * GetVolumeIndexer6D( jlong handle ) { + return (VolumeIndexer6D*)CheckHandle( handle ); + } + inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { return (OpenVDS::VolumeDataLayout *) CheckHandle(handle); } @@ -53,6 +57,186 @@ extern "C" { return 0; } + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpLocalIndexToVoxelIndex + * Signature: (J[IIIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpLocalIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToVoxelIndex(IntVector<6>(i, j, k, l, m, n)); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpLocalIndexToLocalChunkIndex + * Signature: (J[IIIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpLocalIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToLocalChunkIndex(IntVector<6>(i, j, k, l, m, n)); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpVoxelIndexToLocalIndex + * Signature: (J[IIIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpVoxelIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalIndex(IntVector<6>(i, j, k, l, m, n)); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpVoxelIndexToLocalChunkIndex + * Signature: (J[IIIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpVoxelIndexToLocalChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalChunkIndex(IntVector<6>(i, j, k, l, m, n)); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpLocalChunkIndexToLocalIndex + * Signature: (J[IIIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpLocalChunkIndexToLocalIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToLocalIndex(IntVector<6>(i, j, k, l, m, n)); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpLocalChunkIndexToVoxelIndex + * Signature: (J[IIIIIII)V + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpLocalChunkIndexToVoxelIndex + (JNIEnv * env, jclass, jlong handle, jintArray resOutIndex, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToVoxelIndex(IntVector<6>(i, j, k, l, m, n)); + env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpLocalIndexToDataIndex + * Signature: (JIIIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpLocalIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + return GetVolumeIndexer6D(handle)->LocalIndexToDataIndex(IntVector<6>(i, j, k, l, m, n)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpVoxelIndexToDataIndex + * Signature: (JIIIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpVoxelIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + return GetVolumeIndexer6D(handle)->VoxelIndexToDataIndex(IntVector<6>(i, j, k, l, m, n)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpLocalChunkIndexToDataIndex + * Signature: (JIIIIII)I + */ + JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpLocalChunkIndexToDataIndex + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + return GetVolumeIndexer6D(handle)->LocalChunkIndexToDataIndex(IntVector<6>(i, j, k, l, m, n)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpVoxelIndexInProcessArea + * Signature: (JIIIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpVoxelIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + return GetVolumeIndexer6D(handle)->VoxelIndexInProcessArea(IntVector<6>(i, j, k, l, m, n)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpLocalIndexInProcessArea + * Signature: (JIIIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpLocalIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + return GetVolumeIndexer6D(handle)->LocalIndexInProcessArea(IntVector<6>(i, j, k, l, m, n)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + + /* + * Class: org_opengroup_openvds_VolumeIndexer6D + * Method: cpLocalChunkIndexInProcessArea + * Signature: (JIIIIII)Z + */ + JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexer6D_cpLocalChunkIndexInProcessArea + (JNIEnv * env, jclass, jlong handle, jint i, jint j, jint k, jint l, jint m, jint n) + { + try { + return GetVolumeIndexer6D(handle)->LocalChunkIndexInProcessArea(IntVector<6>(i, j, k, l, m, n)); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } + #ifdef __cplusplus } #endif diff --git a/java/cpp/src/VolumeIndexerBase.cpp b/java/cpp/src/VolumeIndexerBase.cpp index 280352b3..41d885e7 100644 --- a/java/cpp/src/VolumeIndexerBase.cpp +++ b/java/cpp/src/VolumeIndexerBase.cpp @@ -182,543 +182,6 @@ extern "C" { return -1; } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpLocalIndexToVoxelIndex - * Signature: (JI[I)[I - */ - JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToVoxelIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex, jintArray resOutIndex) - { - try { - jint *input = env->GetIntArrayElements(localIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToVoxelIndex(vec2); - env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); - break; - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToVoxelIndex(vec3); - env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); - break; - } - case 4:{ - IntVector4 vec4(input[0], input[1], input[2], input[3]); - IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToVoxelIndex(vec4); - env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); - break; - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToVoxelIndex(vec5); - env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); - break; - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToVoxelIndex(vec6); - env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); - break; - } - } - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - } - CATCH_EXCEPTIONS_FOR_JAVA; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpLocalIndexToLocalChunkIndex - * Signature: (JI[I)[I - */ - JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToLocalChunkIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex, jintArray resOutIndex) - { - try { - jint *input = env->GetIntArrayElements(localIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalIndexToLocalChunkIndex(vec2); - env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); - break; - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalIndexToLocalChunkIndex(vec3); - env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); - break; - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalIndexToLocalChunkIndex(vec4); - env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); - break; - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalIndexToLocalChunkIndex(vec5); - env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); - break; - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalIndexToLocalChunkIndex(vec6); - env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); - break; - } - } - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - } - CATCH_EXCEPTIONS_FOR_JAVA; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpVoxelIndexToLocalIndex - * Signature: (JI[I)[I - */ - JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToLocalIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex, jintArray resOutIndex) - { - try { - jint *input = env->GetIntArrayElements(voxelIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalIndex(vec2); - env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); - break; - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalIndex(vec3); - env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); - break; - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalIndex(vec4); - env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); - break; - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalIndex(vec5); - env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); - break; - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalIndex(vec6); - env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); - break; - } - } - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - } - CATCH_EXCEPTIONS_FOR_JAVA; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpVoxelIndexToLocalChunkIndex - * Signature: (JI[I)[I - */ - JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToLocalChunkIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex, jintArray resOutIndex) - { - try { - jint *input = env->GetIntArrayElements(voxelIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - IntVector2 res2 = GetVolumeIndexer2D(handle)->VoxelIndexToLocalChunkIndex(vec2); - env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); - break; - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - IntVector3 res3 = GetVolumeIndexer3D(handle)->VoxelIndexToLocalChunkIndex(vec3); - env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); - break; - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - IntVector4 res4 = GetVolumeIndexer4D(handle)->VoxelIndexToLocalChunkIndex(vec4); - env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); - break; - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - IntVector<5> res5 = GetVolumeIndexer5D(handle)->VoxelIndexToLocalChunkIndex(vec5); - env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); - break; - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - IntVector<6> res6 = GetVolumeIndexer6D(handle)->VoxelIndexToLocalChunkIndex(vec6); - env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); - break; - } - } - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - } - CATCH_EXCEPTIONS_FOR_JAVA; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpLocalChunkIndexToLocalIndex - * Signature: (JI[I)[I - */ - JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToLocalIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex, jintArray resOutIndex) - { - try { - jint *input = env->GetIntArrayElements(localChunkIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToLocalIndex(vec2); - env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); - break; - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToLocalIndex(vec3); - env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); - break; - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToLocalIndex(vec4); - env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); - break; - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToLocalIndex(vec5); - env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); - break; - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToLocalIndex(vec6); - env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); - break; - } - } - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - } - CATCH_EXCEPTIONS_FOR_JAVA; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpLocalChunkIndexToVoxelIndex - * Signature: (JI[I)[I - */ - JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToVoxelIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex, jintArray resOutIndex) - { - try { - jint *input = env->GetIntArrayElements(localChunkIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - IntVector2 res2 = GetVolumeIndexer2D(handle)->LocalChunkIndexToVoxelIndex(vec2); - env->SetIntArrayRegion(resOutIndex, 0, 2, res2.data); - break; - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - IntVector3 res3 = GetVolumeIndexer3D(handle)->LocalChunkIndexToVoxelIndex(vec3); - env->SetIntArrayRegion(resOutIndex, 0, 3, res3.data); - break; - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - IntVector4 res4 = GetVolumeIndexer4D(handle)->LocalChunkIndexToVoxelIndex(vec4); - env->SetIntArrayRegion(resOutIndex, 0, 4, res4.data); - break; - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - IntVector<5> res5 = GetVolumeIndexer5D(handle)->LocalChunkIndexToVoxelIndex(vec5); - env->SetIntArrayRegion(resOutIndex, 0, 5, res5.data); - break; - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - IntVector<6> res6 = GetVolumeIndexer6D(handle)->LocalChunkIndexToVoxelIndex(vec6); - env->SetIntArrayRegion(resOutIndex, 0, 6, res6.data); - break; - } - } - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - } - CATCH_EXCEPTIONS_FOR_JAVA; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpLocalIndexToDataIndex - * Signature: (JI[I)I - */ - JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexToDataIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) - { - try { - jint *input = env->GetIntArrayElements(localIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer2D(handle)->LocalIndexToDataIndex(vec2); - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer3D(handle)->LocalIndexToDataIndex(vec3); - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer4D(handle)->LocalIndexToDataIndex(vec4); - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer5D(handle)->LocalIndexToDataIndex(vec5); - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer6D(handle)->LocalIndexToDataIndex(vec6); - } - } - } - CATCH_EXCEPTIONS_FOR_JAVA; - return -1; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpVoxelIndexToDataIndex - * Signature: (JI[I)I - */ - JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexToDataIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) - { - try { - jint *input = env->GetIntArrayElements(voxelIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer2D(handle)->VoxelIndexToDataIndex(vec2); - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer3D(handle)->VoxelIndexToDataIndex(vec3); - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer4D(handle)->VoxelIndexToDataIndex(vec4); - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer5D(handle)->VoxelIndexToDataIndex(vec5); - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer6D(handle)->VoxelIndexToDataIndex(vec6); - } - } - } - CATCH_EXCEPTIONS_FOR_JAVA; - return -1; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpLocalChunkIndexToDataIndex - * Signature: (JI[I)I - */ - JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexToDataIndex - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) - { - try { - jint *input = env->GetIntArrayElements(localChunkIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer2D(handle)->LocalChunkIndexToDataIndex(vec2); - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer3D(handle)->LocalChunkIndexToDataIndex(vec3); - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer4D(handle)->LocalChunkIndexToDataIndex(vec4); - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer5D(handle)->LocalChunkIndexToDataIndex(vec5); - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer6D(handle)->LocalChunkIndexToDataIndex(vec6); - } - } - } - CATCH_EXCEPTIONS_FOR_JAVA; - return -1; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpVoxelIndexInProcessArea - * Signature: (JI[I)Z - */ - JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpVoxelIndexInProcessArea - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray voxelIndex) - { - try { - jint *input = env->GetIntArrayElements(voxelIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer2D(handle)->VoxelIndexInProcessArea(vec2); - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer3D(handle)->VoxelIndexInProcessArea(vec3); - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer4D(handle)->VoxelIndexInProcessArea(vec4); - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer5D(handle)->VoxelIndexInProcessArea(vec5); - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - env->ReleaseIntArrayElements(voxelIndex, (jint *) input, 0); - return GetVolumeIndexer6D(handle)->VoxelIndexInProcessArea(vec6); - } - } - } - CATCH_EXCEPTIONS_FOR_JAVA; - return -1; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpLocalIndexInProcessArea - * Signature: (JI[I)Z - */ - JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalIndexInProcessArea - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localIndex) - { - try { - jint *input = env->GetIntArrayElements(localIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer2D(handle)->LocalIndexInProcessArea(vec2); - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer3D(handle)->LocalIndexInProcessArea(vec3); - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer4D(handle)->LocalIndexInProcessArea(vec4); - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer5D(handle)->LocalIndexInProcessArea(vec5); - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - env->ReleaseIntArrayElements(localIndex, (jint *) input, 0); - return GetVolumeIndexer6D(handle)->LocalIndexInProcessArea(vec6); - } - } - } - CATCH_EXCEPTIONS_FOR_JAVA; - return -1; - } - - /* - * Class: org_opengroup_openvds_VolumeIndexerBase - * Method: cpLocalChunkIndexInProcessArea - * Signature: (JI[I)Z - */ - JNIEXPORT jboolean JNICALL Java_org_opengroup_openvds_VolumeIndexerBase_cpLocalChunkIndexInProcessArea - (JNIEnv * env, jclass, jlong handle, jint volumeDimension, jintArray localChunkIndex) - { - try { - jint *input = env->GetIntArrayElements(localChunkIndex, 0); - switch (volumeDimension) { - case 2: { - IntVector2 vec2(input[0], input[1]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer2D(handle)->LocalChunkIndexInProcessArea(vec2); - } - case 3: { - IntVector3 vec3(input[0], input[1], input[2]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer3D(handle)->LocalChunkIndexInProcessArea(vec3); - } - case 4: { - IntVector4 vec4(input[0], input[1], input[2], input[3]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer4D(handle)->LocalChunkIndexInProcessArea(vec4); - } - case 5: { - IntVector<5> vec5(input[0], input[1], input[2], input[3], input[4]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer5D(handle)->LocalChunkIndexInProcessArea(vec5); - } - case 6: { - IntVector<6> vec6(input[0], input[1], input[2], input[3], input[4], input[5]); - env->ReleaseIntArrayElements(localChunkIndex, (jint *) input, 0); - return GetVolumeIndexer6D(handle)->LocalChunkIndexInProcessArea(vec6); - } - } - } - CATCH_EXCEPTIONS_FOR_JAVA; - return -1; - - } - - #ifdef __cplusplus } #endif diff --git a/java/java/demo/CreateVDSWithLOD.java b/java/java/demo/CreateVDSWithLOD.java index e50be8fd..f2500351 100644 --- a/java/java/demo/CreateVDSWithLOD.java +++ b/java/java/demo/CreateVDSWithLOD.java @@ -30,7 +30,7 @@ public class CreateVDSWithLOD { static void process(String[] args) throws Exception { - int samplesX = 1000; // time + int samplesX = 1500; // time int samplesY = 2000; // XL int samplesZ = 2000; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; @@ -45,7 +45,7 @@ public class CreateVDSWithLOD { double midY = samplesY / 2f; double midZ = samplesZ / 2f; - VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_128; + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_256; int negativeMargin = 4; int positiveMargin = 4; int brickSize2DMultiplier = 4; @@ -84,7 +84,7 @@ public class CreateVDSWithLOD { //OpenVDS::InMemoryOpenOptions options; - VDSFileOpenOptions options = new VDSFileOpenOptions("/media/hdd/VDS/VDS_LOD_Dome_2000_2000_1000.vds"); + VDSFileOpenOptions options = new VDSFileOpenOptions("/media/hdd/VDS/VDS_LOD_Dome_2000_2000_1500_B256.vds"); VdsError error; MetadataContainer metadataContainer = new MetadataContainer(); @@ -131,7 +131,7 @@ public class CreateVDSWithLOD { DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND lod, // lod channel, // channel - 1000, // max pages + 100, // max pages VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index 19c62e60..60499ac2 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -21,9 +21,11 @@ public class VolumeDataPage extends JniPointer { private static native void cpRelease(long handle); - private static native void cpGetMinMax(long handle, int[] min, int[] max); + private static native void cpGetMinMax(long handle, int[] min, int[] max); - private static native void cpGetMinMaxExcludingMargin(long handle, int[] min, int[] max); + private static native void cpGetMinMaxExcludingMargin(long handle, int[] min, int[] max); + + private static native int cpGetAllocatedSize(long handle); private static native byte[] cpGetByteBuffer(long handle, int[] pitch, int lod); @@ -59,7 +61,8 @@ public class VolumeDataPage extends JniPointer { // Called by JniPointer.release() @Override protected synchronized void deleteHandle() { - // nothing to do. Release page is done by its own method and must be called by the main code, not the finalizer + // nothing to do. Release page is done by its own method and must be called by the main code, not the finalizer + // volume page release is handled by the page accessor and manager } /** @@ -84,6 +87,13 @@ public class VolumeDataPage extends JniPointer { cpGetMinMaxExcludingMargin(_handle, min, max); } + /** + * @return the buffer size of this page + */ + public int getAllocatedBufferSize() { + return cpGetAllocatedSize(_handle); + } + /** * Read byte array of page * @param pitch will receive pitch values for this page @@ -100,7 +110,7 @@ public class VolumeDataPage extends JniPointer { * @param pitch chunk pitch (got by a read) */ public void writeByteBuffer(byte[] buffer, int[] pitch) { - //checkBufferSize(buffer, pitch, dimensionality, lod); + checkBufferSize(buffer, pitch, dimensionality, lod); cpSetByteBuffer(_handle, buffer); } @@ -120,7 +130,7 @@ public class VolumeDataPage extends JniPointer { * @param pitch chunk pitch (got by a read) */ public void writeFloatBuffer(float[] buffer, int[] pitch) { - //checkBufferSize(buffer, pitch, dimensionality, lod); + checkBufferSize(buffer, pitch, dimensionality, lod); cpSetFloatBuffer(_handle, buffer); } @@ -140,7 +150,7 @@ public class VolumeDataPage extends JniPointer { * @param pitch chunk pitch (got by a read) */ public void writeDoubleBuffer(double[] buffer, int[] pitch) { - //checkBufferSize(buffer, pitch, dimensionality, lod); + checkBufferSize(buffer, pitch, dimensionality, lod); cpSetDoubleBuffer(_handle, buffer); } @@ -173,14 +183,9 @@ public class VolumeDataPage extends JniPointer { } private void checkBufferSize(int sizeInputBuffer, int[] pitch, int dim, int lod) { - int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; - int div = (int)Math.pow(2, lod); - getMinMax(chunkMin, chunkMax); - int nbElem = (chunkMax[dim - 1] - chunkMin[dim - 1]) * pitch[dim - 1]; - nbElem /= div; - if (sizeInputBuffer != nbElem) { - throw new IllegalArgumentException("Wrong buffer size, expected " + nbElem + "(dim2 * pitch[2]), got " + sizeInputBuffer); + int pageBufferSize = getAllocatedBufferSize(); + if (sizeInputBuffer != pageBufferSize) { + throw new IllegalArgumentException("Wrong buffer size, expected " + pageBufferSize + ", got " + sizeInputBuffer); } } diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer2D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer2D.java index 4eb98057..dd39e297 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexer2D.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer2D.java @@ -4,12 +4,125 @@ public class VolumeIndexer2D extends VolumeIndexerBase { private static native long cpCreateVolumeIndexer2D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + private static native void cpLocalIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j); + private static native void cpLocalIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j); + + private static native void cpVoxelIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j); + private static native void cpVoxelIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j); + + private static native void cpLocalChunkIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j); + private static native void cpLocalChunkIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j); + + private static native int cpLocalIndexToDataIndex(long handle, int i, int j); + private static native int cpVoxelIndexToDataIndex(long handle, int i, int j); + private static native int cpLocalChunkIndexToDataIndex(long handle, int i, int j); + + private static native boolean cpVoxelIndexInProcessArea(long handle, int i, int j); + private static native boolean cpLocalIndexInProcessArea(long handle, int i, int j); + private static native boolean cpLocalChunkIndexInProcessArea(long handle, int i, int j); + + /** + * Constructor + * @param page + * @param channelIndex + * @param lod + * @param dimensions + * @param layout + */ public VolumeIndexer2D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { super(cpCreateVolumeIndexer2D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 2, true); } + /** + * Constructor + * @param handle + */ public VolumeIndexer2D(long handle) { super(handle, 2, false); } + @Override + public int[] localIndexToVoxelIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToVoxelIndex(_handle, res, localIndex[0], localIndex[1]); + return res; + } + + @Override + public int[] localIndexToLocalChunkIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToLocalChunkIndex(_handle, res, localIndex[0], localIndex[1]); + return res; + } + + @Override + public int[] voxelIndexToLocalIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalIndex(_handle, res, voxelIndex[0], voxelIndex[1]); + return res; + } + + @Override + public int[] voxelIndexToLocalChunkIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalChunkIndex(_handle, res, voxelIndex[0], voxelIndex[1]); + return res; + } + + @Override + public int[] localChunkIndexToLocalIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToLocalIndex(_handle, res, localChunkIndex[0], localChunkIndex[1]); + return res; + } + + @Override + public int[] localChunkIndexToVoxelIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToVoxelIndex(_handle, res, localChunkIndex[0], localChunkIndex[1]); + return res; + } + + @Override + public int localIndexToDataIndex(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexToDataIndex(_handle, localIndex[0], localIndex[1]); + } + + @Override + public int voxelIndexToDataIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexToDataIndex(_handle, voxelIndex[0], voxelIndex[1]); + } + + @Override + public int localChunkIndexToDataIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexToDataIndex(_handle, localChunkIndex[0], localChunkIndex[1]); + } + + @Override + public boolean voxelIndexInProcessArea(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexInProcessArea(_handle, voxelIndex[0], voxelIndex[1]); + } + + @Override + public boolean localIndexInProcessArea(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexInProcessArea(_handle, localIndex[0], localIndex[1]); + } + + @Override + public boolean localChunkIndexInProcessArea(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexInProcessArea(_handle, localChunkIndex[0], localChunkIndex[1]); + } } + diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer3D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer3D.java index 5a3f73db..6602c191 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexer3D.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer3D.java @@ -4,12 +4,124 @@ public class VolumeIndexer3D extends VolumeIndexerBase { private static native long cpCreateVolumeIndexer3D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + private static native void cpLocalIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j, int k); + private static native void cpLocalIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j, int k); + + private static native void cpVoxelIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j, int k); + private static native void cpVoxelIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j, int k); + + private static native void cpLocalChunkIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j, int k); + private static native void cpLocalChunkIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j, int k); + + private static native int cpLocalIndexToDataIndex(long handle, int i, int j, int k); + private static native int cpVoxelIndexToDataIndex(long handle, int i, int j, int k); + private static native int cpLocalChunkIndexToDataIndex(long handle, int i, int j, int k); + + private static native boolean cpVoxelIndexInProcessArea(long handle, int i, int j, int k); + private static native boolean cpLocalIndexInProcessArea(long handle, int i, int j, int k); + private static native boolean cpLocalChunkIndexInProcessArea(long handle, int i, int j, int k); + + /** + * Constructor + * @param page + * @param channelIndex + * @param lod + * @param dimensions + * @param layout + */ public VolumeIndexer3D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { super(cpCreateVolumeIndexer3D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 3, true); } + /** + * Constructor + * @param handle + */ public VolumeIndexer3D(long handle) { super(handle, 3, false); } + @Override + public int[] localIndexToVoxelIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToVoxelIndex(_handle, res, localIndex[0], localIndex[1], localIndex[2]); + return res; + } + + @Override + public int[] localIndexToLocalChunkIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToLocalChunkIndex(_handle, res, localIndex[0], localIndex[1], localIndex[2]); + return res; + } + + @Override + public int[] voxelIndexToLocalIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalIndex(_handle, res, voxelIndex[0], voxelIndex[1], voxelIndex[2]); + return res; + } + + @Override + public int[] voxelIndexToLocalChunkIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalChunkIndex(_handle, res, voxelIndex[0], voxelIndex[1], voxelIndex[2]); + return res; + } + + @Override + public int[] localChunkIndexToLocalIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToLocalIndex(_handle, res, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2]); + return res; + } + + @Override + public int[] localChunkIndexToVoxelIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToVoxelIndex(_handle, res, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2]); + return res; + } + + @Override + public int localIndexToDataIndex(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexToDataIndex(_handle, localIndex[0], localIndex[1], localIndex[2]); + } + + @Override + public int voxelIndexToDataIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexToDataIndex(_handle, voxelIndex[0], voxelIndex[1], voxelIndex[2]); + } + + @Override + public int localChunkIndexToDataIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexToDataIndex(_handle, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2]); + } + + @Override + public boolean voxelIndexInProcessArea(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexInProcessArea(_handle, voxelIndex[0], voxelIndex[1], voxelIndex[2]); + } + + @Override + public boolean localIndexInProcessArea(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexInProcessArea(_handle, localIndex[0], localIndex[1], localIndex[2]); + } + + @Override + public boolean localChunkIndexInProcessArea(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexInProcessArea(_handle, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2]); + } } diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer4D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer4D.java index 9e0ca002..6c329b90 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexer4D.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer4D.java @@ -4,12 +4,124 @@ public class VolumeIndexer4D extends VolumeIndexerBase { private static native long cpCreateVolumeIndexer4D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + private static native void cpLocalIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j, int k, int l); + private static native void cpLocalIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j, int k, int l); + + private static native void cpVoxelIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j, int k, int l); + private static native void cpVoxelIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j, int k, int l); + + private static native void cpLocalChunkIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j, int k, int l); + private static native void cpLocalChunkIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j, int k, int l); + + private static native int cpLocalIndexToDataIndex(long handle, int i, int j, int k, int l); + private static native int cpVoxelIndexToDataIndex(long handle, int i, int j, int k, int l); + private static native int cpLocalChunkIndexToDataIndex(long handle, int i, int j, int k, int l); + + private static native boolean cpVoxelIndexInProcessArea(long handle, int i, int j, int k, int l); + private static native boolean cpLocalIndexInProcessArea(long handle, int i, int j, int k, int l); + private static native boolean cpLocalChunkIndexInProcessArea(long handle, int i, int j, int k, int l); + + /** + * Constructor + * @param page + * @param channelIndex + * @param lod + * @param dimensions + * @param layout + */ public VolumeIndexer4D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { super(cpCreateVolumeIndexer4D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 4, true); } + /** + * Constructor + * @param handle + */ public VolumeIndexer4D(long handle) { super(handle, 4, false); } + @Override + public int[] localIndexToVoxelIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToVoxelIndex(_handle, res, localIndex[0], localIndex[1], localIndex[2], localIndex[3]); + return res; + } + + @Override + public int[] localIndexToLocalChunkIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToLocalChunkIndex(_handle, res, localIndex[0], localIndex[1], localIndex[2], localIndex[3]); + return res; + } + + @Override + public int[] voxelIndexToLocalIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalIndex(_handle, res, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3]); + return res; + } + + @Override + public int[] voxelIndexToLocalChunkIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalChunkIndex(_handle, res, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3]); + return res; + } + + @Override + public int[] localChunkIndexToLocalIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToLocalIndex(_handle, res, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3]); + return res; + } + + @Override + public int[] localChunkIndexToVoxelIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToVoxelIndex(_handle, res, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3]); + return res; + } + + @Override + public int localIndexToDataIndex(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexToDataIndex(_handle, localIndex[0], localIndex[1], localIndex[2], localIndex[3]); + } + + @Override + public int voxelIndexToDataIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexToDataIndex(_handle, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3]); + } + + @Override + public int localChunkIndexToDataIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexToDataIndex(_handle, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3]); + } + + @Override + public boolean voxelIndexInProcessArea(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexInProcessArea(_handle, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3]); + } + + @Override + public boolean localIndexInProcessArea(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexInProcessArea(_handle, localIndex[0], localIndex[1], localIndex[2], localIndex[3]); + } + + @Override + public boolean localChunkIndexInProcessArea(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexInProcessArea(_handle, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3]); + } } diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer5D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer5D.java index 1d2ddedf..b6604385 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexer5D.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer5D.java @@ -4,12 +4,124 @@ public class VolumeIndexer5D extends VolumeIndexerBase { private static native long cpCreateVolumeIndexer5D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + private static native void cpLocalIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j, int k, int l, int n); + private static native void cpLocalIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j, int k, int l, int n); + + private static native void cpVoxelIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j, int k, int l, int n); + private static native void cpVoxelIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j, int k, int l, int n); + + private static native void cpLocalChunkIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j, int k, int l, int n); + private static native void cpLocalChunkIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j, int k, int l, int n); + + private static native int cpLocalIndexToDataIndex(long handle, int i, int j, int k, int l, int n); + private static native int cpVoxelIndexToDataIndex(long handle, int i, int j, int k, int l, int n); + private static native int cpLocalChunkIndexToDataIndex(long handle, int i, int j, int k, int l, int n); + + private static native boolean cpVoxelIndexInProcessArea(long handle, int i, int j, int k, int l, int n); + private static native boolean cpLocalIndexInProcessArea(long handle, int i, int j, int k, int l, int n); + private static native boolean cpLocalChunkIndexInProcessArea(long handle, int i, int j, int k, int l, int n); + + /** + * Constructor + * @param page + * @param channelIndex + * @param lod + * @param dimensions + * @param layout + */ public VolumeIndexer5D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { super(cpCreateVolumeIndexer5D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 5, true); } + /** + * Constructor + * @param handle + */ public VolumeIndexer5D(long handle) { super(handle, 5, false); } + @Override + public int[] localIndexToVoxelIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToVoxelIndex(_handle, res, localIndex[0], localIndex[1], localIndex[2], localIndex[3], localIndex[4]); + return res; + } + + @Override + public int[] localIndexToLocalChunkIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToLocalChunkIndex(_handle, res, localIndex[0], localIndex[1], localIndex[2], localIndex[3], localIndex[4]); + return res; + } + + @Override + public int[] voxelIndexToLocalIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalIndex(_handle, res, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3], voxelIndex[4]); + return res; + } + + @Override + public int[] voxelIndexToLocalChunkIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalChunkIndex(_handle, res, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3], voxelIndex[4]); + return res; + } + + @Override + public int[] localChunkIndexToLocalIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToLocalIndex(_handle, res, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3], localChunkIndex[4]); + return res; + } + + @Override + public int[] localChunkIndexToVoxelIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToVoxelIndex(_handle, res, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3], localChunkIndex[4]); + return res; + } + + @Override + public int localIndexToDataIndex(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexToDataIndex(_handle, localIndex[0], localIndex[1], localIndex[2], localIndex[3], localIndex[4]); + } + + @Override + public int voxelIndexToDataIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexToDataIndex(_handle, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3], voxelIndex[4]); + } + + @Override + public int localChunkIndexToDataIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexToDataIndex(_handle, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3], localChunkIndex[4]); + } + + @Override + public boolean voxelIndexInProcessArea(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexInProcessArea(_handle, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3], voxelIndex[4]); + } + + @Override + public boolean localIndexInProcessArea(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexInProcessArea(_handle, localIndex[0], localIndex[1], localIndex[2], localIndex[3], localIndex[4]); + } + + @Override + public boolean localChunkIndexInProcessArea(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexInProcessArea(_handle, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3], localChunkIndex[4]); + } } diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexer6D.java b/java/java/src/org/opengroup/openvds/VolumeIndexer6D.java index 6ae7d8f0..7960ea92 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexer6D.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexer6D.java @@ -4,12 +4,124 @@ public class VolumeIndexer6D extends VolumeIndexerBase { private static native long cpCreateVolumeIndexer6D(long pageHandle, int channelIndex, int lod, int dimensions, long layoutHandle); + private static native void cpLocalIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j, int k, int l, int m, int n); + private static native void cpLocalIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j, int k, int l, int m, int n); + + private static native void cpVoxelIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j, int k, int l, int m, int n); + private static native void cpVoxelIndexToLocalChunkIndex(long handle, int[] localChunkIndexRes, int i, int j, int k, int l, int m, int n); + + private static native void cpLocalChunkIndexToLocalIndex(long handle, int[] localIndexRes, int i, int j, int k, int l, int m, int n); + private static native void cpLocalChunkIndexToVoxelIndex(long handle, int[] voxelIndexRes, int i, int j, int k, int l, int m, int n); + + private static native int cpLocalIndexToDataIndex(long handle, int i, int j, int k, int l, int m, int n); + private static native int cpVoxelIndexToDataIndex(long handle, int i, int j, int k, int l, int m, int n); + private static native int cpLocalChunkIndexToDataIndex(long handle, int i, int j, int k, int l, int m, int n); + + private static native boolean cpVoxelIndexInProcessArea(long handle, int i, int j, int k, int l, int m, int n); + private static native boolean cpLocalIndexInProcessArea(long handle, int i, int j, int k, int l, int m, int n); + private static native boolean cpLocalChunkIndexInProcessArea(long handle, int i, int j, int k, int l, int m, int n); + + /** + * Constructor + * @param page + * @param channelIndex + * @param lod + * @param dimensions + * @param layout + */ public VolumeIndexer6D(VolumeDataPage page, int channelIndex, int lod, int dimensions, VolumeDataLayout layout) { super(cpCreateVolumeIndexer6D(page.handle(), channelIndex, lod, dimensions, layout.handle()), 6, true); } + /** + * Constructor + * @param handle + */ public VolumeIndexer6D(long handle) { super(handle, 6, false); } + @Override + public int[] localIndexToVoxelIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToVoxelIndex(_handle, res, localIndex[0], localIndex[1], localIndex[2], localIndex[3], localIndex[4], localIndex[5]); + return res; + } + + @Override + public int[] localIndexToLocalChunkIndex(int[] localIndex) { + checkIndexArgument(localIndex); + int[] res = new int[localIndex.length]; + cpLocalIndexToLocalChunkIndex(_handle, res, localIndex[0], localIndex[1], localIndex[2], localIndex[3], localIndex[4], localIndex[5]); + return res; + } + + @Override + public int[] voxelIndexToLocalIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalIndex(_handle, res, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3], voxelIndex[4], voxelIndex[5]); + return res; + } + + @Override + public int[] voxelIndexToLocalChunkIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + int[] res = new int[voxelIndex.length]; + cpVoxelIndexToLocalChunkIndex(_handle, res, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3], voxelIndex[4], voxelIndex[5]); + return res; + } + + @Override + public int[] localChunkIndexToLocalIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToLocalIndex(_handle, res, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3], localChunkIndex[4], localChunkIndex[5]); + return res; + } + + @Override + public int[] localChunkIndexToVoxelIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + int[] res = new int[localChunkIndex.length]; + cpLocalChunkIndexToVoxelIndex(_handle, res, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3], localChunkIndex[4], localChunkIndex[5]); + return res; + } + + @Override + public int localIndexToDataIndex(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexToDataIndex(_handle, localIndex[0], localIndex[1], localIndex[2], localIndex[3], localIndex[4], localIndex[5]); + } + + @Override + public int voxelIndexToDataIndex(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexToDataIndex(_handle, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3], voxelIndex[4], voxelIndex[5]); + } + + @Override + public int localChunkIndexToDataIndex(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexToDataIndex(_handle, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3], localChunkIndex[4], localChunkIndex[5]); + } + + @Override + public boolean voxelIndexInProcessArea(int[] voxelIndex) { + checkIndexArgument(voxelIndex); + return cpVoxelIndexInProcessArea(_handle, voxelIndex[0], voxelIndex[1], voxelIndex[2], voxelIndex[3], voxelIndex[4], voxelIndex[5]); + } + + @Override + public boolean localIndexInProcessArea(int[] localIndex) { + checkIndexArgument(localIndex); + return cpLocalIndexInProcessArea(_handle, localIndex[0], localIndex[1], localIndex[2], localIndex[3], localIndex[4], localIndex[5]); + } + + @Override + public boolean localChunkIndexInProcessArea(int[] localChunkIndex) { + checkIndexArgument(localChunkIndex); + return cpLocalChunkIndexInProcessArea(_handle, localChunkIndex[0], localChunkIndex[1], localChunkIndex[2], localChunkIndex[3], localChunkIndex[4], localChunkIndex[5]); + } } diff --git a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java index 451086ec..abf613f3 100644 --- a/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java +++ b/java/java/src/org/opengroup/openvds/VolumeIndexerBase.java @@ -9,24 +9,7 @@ public abstract class VolumeIndexerBase extends JniPointer { private static native int cpGetDataBlockNumSamples(long handle, int volumeDimension, int dim); private static native int cpGetLocalChunkNumSamples(long handle, int volumeDimension, int dim); - private static native void cpLocalIndexToVoxelIndex(long handle, int volumeDimension, int[] localIndex, int[] voxelIndexRes); - private static native void cpLocalIndexToLocalChunkIndex(long handle, int volumeDimension, int[] localIndex, int[] localChunkIndexRes); - - private static native void cpVoxelIndexToLocalIndex(long handle, int volumeDimension, int[] voxelIndex, int[] localIndexRes); - private static native void cpVoxelIndexToLocalChunkIndex(long handle, int volumeDimension, int[] voxelIndex, int[] localChunkIndexRes); - - private static native void cpLocalChunkIndexToLocalIndex(long handle, int volumeDimension, int[] localChunkIndex, int[] localIndexRes); - private static native void cpLocalChunkIndexToVoxelIndex(long handle, int volumeDimension, int[] localChunkIndex, int[] voxelIndexRes); - - private static native int cpLocalIndexToDataIndex(long handle, int volumeDimension, int[] localIndex); - private static native int cpVoxelIndexToDataIndex(long handle, int volumeDimension, int[] voxelIndex); - private static native int cpLocalChunkIndexToDataIndex(long handle, int volumeDimension, int[] localChunkIndex); - - private static native boolean cpVoxelIndexInProcessArea(long handle, int volumeDimension, int[] voxelIndex); - private static native boolean cpLocalIndexInProcessArea(long handle, int volumeDimension, int[] voxelIndex); - private static native boolean cpLocalChunkIndexInProcessArea(long handle, int volumeDimension, int[] voxelIndex); - - private final int dimensionVolume; + protected final int dimensionVolume; public VolumeIndexerBase(long handle, int dimension, boolean ownHandle) { super(handle, ownHandle); @@ -71,134 +54,87 @@ public abstract class VolumeIndexerBase extends JniPointer { * @param localIndex the local index to convert * @return the voxel index */ - public int[] localIndexToVoxelIndex(int[] localIndex) { - checkLocalIndexArgument(localIndex); - int[] res = new int[localIndex.length]; - cpLocalIndexToVoxelIndex(_handle, dimensionVolume, localIndex, res); - return res; - } + public abstract int[] localIndexToVoxelIndex(int[] localIndex); /** * Converts a local index to a local chunk index * @param localIndex the local index to convert * @return the local chunk index */ - public int[] localIndexToLocalChunkIndex(int[] localIndex) { - checkLocalIndexArgument(localIndex); - int[] res = new int[localIndex.length]; - cpLocalIndexToLocalChunkIndex(_handle, dimensionVolume, localIndex, res); - return res; - } + public abstract int[] localIndexToLocalChunkIndex(int[] localIndex); /** * Converts a voxel index to a local index * @param voxelIndex the voxel index to convert * @return the local index */ - public int[] voxelIndexToLocalIndex(int[] voxelIndex) { - checkLocalIndexArgument(voxelIndex); - int[] res = new int[voxelIndex.length]; - cpVoxelIndexToLocalIndex(_handle, dimensionVolume, voxelIndex, res); - return res; - } + public abstract int[] voxelIndexToLocalIndex(int[] voxelIndex); /** * Converts a voxel index to a local chunk index * @param voxelIndex the voxel index to convert * @return the local index */ - public int[] voxelIndexToLocalChunkIndex(int[] voxelIndex) { - checkLocalIndexArgument(voxelIndex); - int[] res = new int[voxelIndex.length]; - cpVoxelIndexToLocalChunkIndex(_handle, dimensionVolume, voxelIndex, res); - return res; - } + public abstract int[] voxelIndexToLocalChunkIndex(int[] voxelIndex); /** * Converts a local chunk index to a local index * @param localChunkIndex the local chunk index to convert * @return the local index */ - public int[] localChunkIndexToLocalIndex(int[] localChunkIndex) { - checkLocalIndexArgument(localChunkIndex); - int[] res = new int[localChunkIndex.length]; - cpLocalChunkIndexToLocalIndex(_handle, dimensionVolume, localChunkIndex, res); - return res; - } + public abstract int[] localChunkIndexToLocalIndex(int[] localChunkIndex); /** * Converts a local chunk index to a voxel index * @param localChunkIndex * @return the local voxel index */ - public int[] localChunkIndexToVoxelIndex(int[] localChunkIndex) { - checkLocalIndexArgument(localChunkIndex); - int[] res = new int[localChunkIndex.length]; - cpLocalChunkIndexToVoxelIndex(_handle, dimensionVolume, localChunkIndex, res); - return res; - } + public abstract int[] localChunkIndexToVoxelIndex(int[] localChunkIndex); /** * Converts a local index to a data index * @param localIndex the local index to convert * @return the buffer offset (position) for the local index */ - public int localIndexToDataIndex(int[] localIndex) { - checkLocalIndexArgument(localIndex); - return cpLocalIndexToDataIndex(_handle, dimensionVolume, localIndex); - } + public abstract int localIndexToDataIndex(int[] localIndex); /** * Converts a voxel index to a data index * @param voxelIndex the voxel index to convert * @return the buffer offset for the voxel index */ - public int voxelIndexToDataIndex(int[] voxelIndex) { - checkLocalIndexArgument(voxelIndex); - return cpVoxelIndexToDataIndex(_handle, dimensionVolume, voxelIndex); - } + public abstract int voxelIndexToDataIndex(int[] voxelIndex); /** * Converts a voxel index to a data index * @param localChunkIndex the local chunk index to convert * @return the buffer offset for the local chunk index */ - public int localChunkIndexToDataIndex(int[] localChunkIndex) { - checkLocalIndexArgument(localChunkIndex); - return cpLocalChunkIndexToDataIndex(_handle, dimensionVolume, localChunkIndex); - } + public abstract int localChunkIndexToDataIndex(int[] localChunkIndex); /** * Checks if a voxel index is within the chunk this indexer was created with * @param voxelIndex the voxel index to check * @return true if the index is within this chunk, false otherwise */ - public boolean voxelIndexInProcessArea(int[] voxelIndex) { - checkLocalIndexArgument(voxelIndex); - return cpVoxelIndexInProcessArea(_handle, dimensionVolume, voxelIndex); - } + public abstract boolean voxelIndexInProcessArea(int[] voxelIndex); /** * Checks if a local index is within the chunk this indexer was created with * @param localIndex the local index to check * @return true if the index is within this chunk, false otherwise */ - public boolean localIndexInProcessArea(int[] localIndex) { - checkLocalIndexArgument(localIndex); - return cpLocalIndexInProcessArea(_handle, dimensionVolume, localIndex); - } + public abstract boolean localIndexInProcessArea(int[] localIndex); /** * Checks if a local chunk index is within the chunk this indexer was created with * @param localChunkIndex the local chunk index to check * @return true if the index is within this chunk, false otherwise */ - public boolean localChunkIndexInProcessArea(int[] localChunkIndex) { - checkLocalIndexArgument(localChunkIndex); - return cpLocalChunkIndexInProcessArea(_handle, dimensionVolume, localChunkIndex); - } + public abstract boolean localChunkIndexInProcessArea(int[] localChunkIndex); + - private void checkLocalIndexArgument(int[] localIndex) { + protected void checkIndexArgument(int[] localIndex) { if (localIndex == null || localIndex.length != dimensionVolume) { throw new IllegalArgumentException("Local index size must match indexer dimension. Expected " + dimensionVolume + ", got " + (localIndex != null ? localIndex.length : "null")); } diff --git a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp index 1524d5d3..8537ed8c 100644 --- a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp +++ b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp @@ -66,6 +66,7 @@ int64_t GetTotalSystemMemory() #include #include +#include void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ); @@ -106,13 +107,21 @@ getScaleOffsetForFormat(float min, float max, bool novalue, OpenVDS::VolumeDataC int main(int argc, char *argv[]) { - int32_t samplesX = 250; - int32_t samplesY = 400; - int32_t samplesZ = 400; + int32_t samplesX = 500; + int32_t samplesY = 800; + int32_t samplesZ = 800; + + std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); - //createNoLODVDS(samplesX, samplesY, samplesZ); - createLODVDS(samplesX, samplesY, samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels_2); + createNoLODVDS(samplesX, samplesY, samplesZ); + //createLODVDS(samplesX, samplesY, samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels_2); + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); + long elapsed = std::chrono::duration_cast(end - begin).count(); + long hrs = elapsed / (60 * 60 * 1000); + long min = (elapsed - (hrs * 60 * 60 * 1000)) / (60 * 1000); + long s = (elapsed - (hrs * 60 * 1000) - (min * 60 * 1000)) / 1000; + std::cout << "Write VDS TIME [CPP native] : " << hrs << " hrs " << min << " min " << s << "s (" << elapsed << " ms)" << std::endl; return EXIT_SUCCESS; } @@ -201,8 +210,8 @@ void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ) { for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { OpenVDS::IntVector<3> localOutIndex(iDim0, iDim1, iDim2); - - float value = (float) ((iDim0 + iDim1 + iDim2)%numSamples[0]) / numSamples[0]; + OpenVDS::IntVector<3> vox = outputIndexer.LocalIndexToVoxelIndex(localOutIndex); + float value = (float) ((vox[0] + vox[1] + vox[2])) / numSamples[0]; value = rangeMin + 2.f * value; int dataPos = outputIndexer.LocalIndexToDataIndex(localOutIndex); output[dataPos] = value; -- GitLab From c3213f13e965973d4625a72b354c26c20728946d Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Fri, 23 Apr 2021 16:55:38 +0200 Subject: [PATCH 019/194] Get Chunk index from position in page accessor (+ test) Param for output files in demo files (maybe to do : params for dimension) --- java/cpp/src/VolumeDataPage.cpp | 17 ++++ java/cpp/src/VolumeDataPageAccessor.cpp | 19 ++++ java/java/demo/CreateVDS.java | 88 ++++++++++-------- java/java/demo/CreateVDSWithLOD.java | 89 ++++++++++++++----- .../org/opengroup/openvds/VolumeDataPage.java | 10 +++ .../openvds/VolumeDataPageAccessor.java | 19 +++- .../opengroup/openvds/PageAccessorTest.java | 56 ++++++++++++ tools/ScratchVDSFileCreate/VDSFileCreate.cpp | 68 +++++++++----- 8 files changed, 286 insertions(+), 80 deletions(-) diff --git a/java/cpp/src/VolumeDataPage.cpp b/java/cpp/src/VolumeDataPage.cpp index bf9efebe..540fb856 100644 --- a/java/cpp/src/VolumeDataPage.cpp +++ b/java/cpp/src/VolumeDataPage.cpp @@ -103,6 +103,23 @@ extern "C" { return -1; } + /* + * Class: org_opengroup_openvds_VolumeDataPage + * Method: cpGetPitch + * Signature: (J[I)[I + */ + JNIEXPORT void JNICALL Java_org_opengroup_openvds_VolumeDataPage_cpGetPitch + (JNIEnv * env, jclass, jlong handle, jintArray pitchArray) + { + try { + int pitch[OpenVDS::Dimensionality_Max]; + OpenVDS::VolumeDataPage* page = GetVolumePage(handle); + page->GetBuffer(pitch); + env->SetIntArrayRegion(pitchArray, 0, OpenVDS::Dimensionality_Max, pitch); + } + CATCH_EXCEPTIONS_FOR_JAVA; + } + /* * Class: org_opengroup_openvds_VolumeDataPage * Method: cpGetByteBuffer diff --git a/java/cpp/src/VolumeDataPageAccessor.cpp b/java/cpp/src/VolumeDataPageAccessor.cpp index 5292f89b..dad09d6b 100644 --- a/java/cpp/src/VolumeDataPageAccessor.cpp +++ b/java/cpp/src/VolumeDataPageAccessor.cpp @@ -175,6 +175,25 @@ extern "C" { CATCH_EXCEPTIONS_FOR_JAVA; } + /* + * Class: org_opengroup_openvds_VolumeDataPageAccessor + * Method: cpGetChunkIndex + * Signature: (J[I)J + */ + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataPageAccessor_cpGetChunkIndex + (JNIEnv * env, jclass, jlong handle, jintArray positionArr) + { + try { + jint * position = env->GetIntArrayElements(positionArr, 0); + //const int (&positionParam)[OpenVDS::Dimensionality_Max] = reinterpret_cast(position); + int positionParam[OpenVDS::Dimensionality_Max]; + for (int i = 0 ; i < OpenVDS::Dimensionality_Max ; ++i) positionParam[i] = position[i]; + env->ReleaseIntArrayElements(positionArr, position, 0); + return GetPageAccessor( handle )->GetChunkIndex(positionParam); + } + CATCH_EXCEPTIONS_FOR_JAVA; + return -1; + } /* * Class: org_opengroup_openvds_VolumeDataPageAccessor diff --git a/java/java/demo/CreateVDS.java b/java/java/demo/CreateVDS.java index 4d4a07cc..05db8fb4 100644 --- a/java/java/demo/CreateVDS.java +++ b/java/java/demo/CreateVDS.java @@ -1,5 +1,7 @@ import org.opengroup.openvds.*; +import java.io.File; +import java.io.IOException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -9,15 +11,21 @@ public class CreateVDS { public static void main(String[] args) { try { - Instant start = Instant.now(); - process(args); - Instant end = Instant.now(); - - Duration elapsed = Duration.between(start, end); - long hrs = elapsed.toHours(); - long min = elapsed.toMinutes() - (hrs * 60); - long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; - System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + if (!checkParams(args)) { + System.out.println("Bad params, usage : /path/to/file"); + System.out.println("path must be a valid non existing file path"); + } + else { + Instant start = Instant.now(); + process(args[0]); + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } } catch (Throwable t) { System.out.println(); @@ -25,7 +33,31 @@ public class CreateVDS { } } - static void process(String[] args) throws Exception { + private static boolean checkParams(String[] args) { + if (args == null || args.length != 1) { + return false; + } + String path = args[0]; + File file = new File(path); + try { + file.getCanonicalPath(); + } + catch (IOException e) { + System.err.println("VDS File path is invalid !"); + return false; + } + if (!path.endsWith(".vds")) { + System.err.println("VDS File path must have vds extension !"); + return false; + } + if (file.exists()) { + System.err.println("VDS File already exists !"); + return false; + } + return true; + } + + static void process(String vdsPath) throws Exception { int samplesX = 500; // time int samplesY = 800; // XL @@ -81,7 +113,7 @@ public class CreateVDS { //OpenVDS::InMemoryOpenOptions options; - VDSFileOpenOptions options = new VDSFileOpenOptions("/tmp/testCreate.vds"); + VDSFileOpenOptions options = new VDSFileOpenOptions(vdsPath); VdsError error; MetadataContainer metadataContainer = new MetadataContainer(); @@ -121,7 +153,6 @@ public class CreateVDS { VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode //ASSERT_TRUE(pageAccessor); - int dimensionality = layout.getDimensionality(); int chunkCount = (int) pageAccessor.getChunkCount(); System.out.println("Chunk count : " + chunkCount); @@ -130,47 +161,30 @@ public class CreateVDS { long timeWrite = 0L; long timeVolIndex = 0L; + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] numSamplesChunk = new int[3]; + int[] localChunkIndex = new int[3]; + int[] voxelPos = new int[3]; + for (int i = 0; i < chunkCount; i++) { long time_1 = System.currentTimeMillis(); VolumeDataPage page = pageAccessor.createPage(i); - System.out.print("Page " + (i+1) + " / " + chunkCount); + System.out.println("Page " + (i+1) + " / " + chunkCount); VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, 0, DimensionsND.DIMENSIONS_012.ordinal(), layout); - float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); - - int[] numSamplesChunk = new int[3]; - int[] numSamplesDB = new int[3]; for (int j = 0; j < 3; j++) { numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); - numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); } - System.out.print(" Dimensions : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); - - int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; - - page.getMinMax(chunkMin, chunkMax); - - System.out.print(" Coords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[2] + "/" + chunkMax[2]); - int chunkSizeY = chunkMax[2] - chunkMin[2]; - int chunkSizeX = chunkMax[1] - chunkMin[1]; - int chunkSizeZ = chunkMax[0] - chunkMin[0]; - - float[] output = page.readFloatBuffer(pitch); - // dimension of buffer - System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); - int dimPitch = pitch[dimensionality - 1] * (chunkMax[dimensionality - 1] - chunkMin[dimensionality - 1]); + page.getPitch(pitch); + float[] output = new float[page.getAllocatedBufferSize()]; long time_2 = System.currentTimeMillis(); int[] numSamples = numSamplesChunk; - int[] localChunkIndex = new int[3]; - int[] voxelPos = new int[3]; for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { diff --git a/java/java/demo/CreateVDSWithLOD.java b/java/java/demo/CreateVDSWithLOD.java index f2500351..b10b9130 100644 --- a/java/java/demo/CreateVDSWithLOD.java +++ b/java/java/demo/CreateVDSWithLOD.java @@ -1,5 +1,7 @@ import org.opengroup.openvds.*; +import java.io.File; +import java.io.IOException; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -10,17 +12,25 @@ import java.util.stream.IntStream; public class CreateVDSWithLOD { + // usage : CreateVDSWithLOD n /path/to/file + // where n is the LOD level wanted public static void main(String[] args) { try { - Instant start = Instant.now(); - process(args); - Instant end = Instant.now(); - - Duration elapsed = Duration.between(start, end); - long hrs = elapsed.toHours(); - long min = elapsed.toMinutes() - (hrs * 60); - long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; - System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + if (!checkParams(args)) { + System.out.println("Bad params, usage : n /path/to/file"); + System.out.println("where n is the LOD level wanted (0 <= lod <= 12), path must be a valid non existing file path"); + } + else { + Instant start = Instant.now(); + process(Integer.parseInt(args[0]), args[1]); + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } } catch (Throwable t) { System.out.println(); @@ -28,7 +38,40 @@ public class CreateVDSWithLOD { } } - static void process(String[] args) throws Exception { + private static boolean checkParams(String[] args) { + if (args == null || args.length != 2) { + return false; + } + try { + Integer lod = Integer.parseInt(args[0]); + if (lod < 0 || lod > 12) { + return false; + } + } + catch (NumberFormatException nfe) { + return false; + } + String path = args[1]; + File file = new File(path); + try { + file.getCanonicalPath(); + } + catch (IOException e) { + System.err.println("VDS File path is invalid !"); + return false; + } + if (!path.endsWith(".vds")) { + System.err.println("VDS File path must have vds extension !"); + return false; + } + if (file.exists()) { + System.err.println("VDS File already exists !"); + return false; + } + return true; + } + + static void process(int lodParam, String vdsFilePath) throws Exception { int samplesX = 1500; // time int samplesY = 2000; // XL @@ -49,7 +92,9 @@ public class CreateVDSWithLOD { int negativeMargin = 4; int positiveMargin = 4; int brickSize2DMultiplier = 4; - VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.LOD_LEVELS_3; + + VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.values()[lodParam]; + //VolumeDataLayoutDescriptor.Options layoutOptions = VolumeDataLayoutDescriptor.Options.NONE; VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, brickSize2DMultiplier, lodLevels, false,false,0); @@ -84,7 +129,7 @@ public class CreateVDSWithLOD { //OpenVDS::InMemoryOpenOptions options; - VDSFileOpenOptions options = new VDSFileOpenOptions("/media/hdd/VDS/VDS_LOD_Dome_2000_2000_1500_B256.vds"); + VDSFileOpenOptions options = new VDSFileOpenOptions(vdsFilePath); VdsError error; MetadataContainer metadataContainer = new MetadataContainer(); @@ -125,6 +170,10 @@ public class CreateVDSWithLOD { int[] localIndex = new int[3]; int[] voxelPos = new int[3]; + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + for (int lod = 0 ; lod <= lodCount ; ++lod) { VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( layout, // layout @@ -160,12 +209,8 @@ public class CreateVDSWithLOD { numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); } - System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); - System.out.print("\tDimensions DataBlok : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); - - int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; - int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); + System.out.print("\tDimensions DataBlock : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); page.getMinMax(chunkMin, chunkMax); @@ -174,7 +219,13 @@ public class CreateVDSWithLOD { int chunkSizeX = chunkMax[1] - chunkMin[1]; int chunkSizeZ = chunkMax[0] - chunkMin[0]; + // get pitch and allocate buffer size + //page.getPitch(pitch); + //float[] output = new float[page.getAllocatedBufferSize()]; + + // or read buffer of page float[] output = page.readFloatBuffer(pitch); + DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); DoubleSummaryStatistics stats = ds.summaryStatistics(); System.out.print( " Page Buffer Size : " + output.length + " / [" + stats.getMin() + "," + stats.getMax() + "]"); @@ -230,8 +281,6 @@ public class CreateVDSWithLOD { displayStatistics(timeRead, timeVolIndex, timeWrite); - - vds.close(); // equivalent to OpenVDS.close(vds); ? System.out.println("VDS closed"); } diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPage.java b/java/java/src/org/opengroup/openvds/VolumeDataPage.java index 60499ac2..2599217b 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPage.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPage.java @@ -27,6 +27,8 @@ public class VolumeDataPage extends JniPointer { private static native int cpGetAllocatedSize(long handle); + private static native void cpGetPitch(long handle, int[] pitch); + private static native byte[] cpGetByteBuffer(long handle, int[] pitch, int lod); private static native void cpSetByteBuffer(long handle, byte[] buffer); @@ -94,6 +96,14 @@ public class VolumeDataPage extends JniPointer { return cpGetAllocatedSize(_handle); } + /** + * Read the pitch of this volume page and puts it in pitch array parameter + */ + public void getPitch(int pitch[]) { + checkDimParamArray(pitch, "Wrong pitch array parameter size, expected "); + cpGetPitch(_handle, pitch); + } + /** * Read byte array of page * @param pitch will receive pitch values for this page diff --git a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java index 64ea7827..c7e79bc2 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataPageAccessor.java @@ -26,6 +26,7 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { private static native long cpGetChunkCount( long handle ); private static native void cpGetChunkMinMax( long handle, int chunk, int[] chunkMin, int[] chunkMax); private static native void cpGetChunkMinMaxExcludingMargin( long handle, int chunk, int[] chunkMin, int[] chunkMax); + private static native long cpGetChunkIndex(long handle, int[] position); private static native long cpCreatePage( long handle, long chunkIndex); private static native long cpReadPage( long handle, long chunkIndex); private static native void cpCommit(long handle); @@ -85,8 +86,6 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { cpGetChunkMinMax(_handle, chunk, chunkMin, chunkMax); } - - /** * Get chunk dimension (without margin) * @param chunk chunk index @@ -99,6 +98,16 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { cpGetChunkMinMaxExcludingMargin(_handle, chunk, chunkMin, chunkMax); } + /** + * Get index of chunk for a given position + * @param position voxel position (array must be VolumeDataLayout.Dimensionality_Max size) + * @return chunk position + */ + public long getChunkIndex(int[] position) { + checkPosition(position); + return cpGetChunkIndex(_handle, position); + } + /** * Create page for given chunk index * @param chunkIndex @@ -140,6 +149,12 @@ public class VolumeDataPageAccessor extends JniPointerWithoutDeletion { cpSetMaxPage(_handle, maxPages); } + private void checkPosition(int[] position) { + if (position == null || position.length != VolumeDataLayout.Dimensionality_Max) { + throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkIndex : wrong position vector"); + } + } + private void checkChunkAndArraySize(int chunk, int[] chunkMin, int[] chunkMax) { if (chunk < 0 || chunk >= getChunkCount()) { throw new IllegalArgumentException("VolumeDataPageAccessor::getChunkMinMax : wrong chunk index"); diff --git a/java/java/test/org/opengroup/openvds/PageAccessorTest.java b/java/java/test/org/opengroup/openvds/PageAccessorTest.java index 328ffedc..7700f458 100644 --- a/java/java/test/org/opengroup/openvds/PageAccessorTest.java +++ b/java/java/test/org/opengroup/openvds/PageAccessorTest.java @@ -211,6 +211,7 @@ public class PageAccessorTest { // compares block data int[] pitchInput = new int[VolumeDataLayout.Dimensionality_Max]; int[] pitchOutput = new int[VolumeDataLayout.Dimensionality_Max]; + long chunkCount = pageAccessorInput.getChunkCount(); for (long chunk = 0 ; chunk < chunkCount ; ++chunk) { VolumeDataPage inputPage = pageAccessorInput.readPage(chunk); @@ -235,4 +236,59 @@ public class PageAccessorTest { } } + /** + * Will test that copied file is the same as the input + * Name of method is the same + Suffix so that it's executed after the copy test + */ + @Test + public void testCopyPageAccessorValidationChunkIndex() { + try { + String tmpDir = System.getProperty("java.io.tmpdir"); + String vdsPath = tmpDir + File.separator + TEMP_FILE_NAME_COPY; + VDSFileOpenOptions options = new VDSFileOpenOptions(vdsPath); + VdsHandle vdsCopy = OpenVDS.open(options); + VolumeDataAccessManager accessManager = vdsCopy.getAccessManager(); + + int channel = 0; + VolumeDataLayout layout = vdsCopy.getLayout(); + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + 0, // lod + channel, // channel + 20, // max pages + VolumeDataAccessManager.AccessMode.ReadOnly.getCode()); // access mode + + // compares block data + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMaxPos = new int[VolumeDataLayout.Dimensionality_Max]; + + long chunkCount = pageAccessor.getChunkCount(); + for (long chunk = 0 ; chunk < chunkCount ; ++chunk) { + VolumeDataPage inputPage = pageAccessor.readPage(chunk); + + // check that chunk index matches current index + inputPage.getMinMaxExcludingMargin(chunkMin, chunkMax); + for (int i = 0 ; i < VolumeDataLayout.Dimensionality_Max ; ++i) { + chunkMaxPos[i] = chunkMax[i] != 0 ? chunkMax[i] - 1 : chunkMax[i]; + } + long idxChMin = pageAccessor.getChunkIndex(chunkMin); + long idxChMax = pageAccessor.getChunkIndex(chunkMaxPos); + + Assert.assertEquals(chunk, idxChMin); + Assert.assertEquals(idxChMin, idxChMax); + + inputPage.pageRelease(); + } + + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + + vdsCopy.close(); + } + catch (java.io.IOException e) { + System.out.println(e.getMessage()); + fail(); + } +} } diff --git a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp index 8537ed8c..4c6e12b5 100644 --- a/tools/ScratchVDSFileCreate/VDSFileCreate.cpp +++ b/tools/ScratchVDSFileCreate/VDSFileCreate.cpp @@ -69,8 +69,8 @@ int64_t GetTotalSystemMemory() #include -void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ); -void createLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels); +void createNoLODVDS(const std::string &vdsFileName, int32_t samplesX, int32_t samplesY, int32_t samplesZ); +void createLODVDS(const std::string &vdsFileName, int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels); double distance2D(double x1, double y1, double x2, double y2); double distance3D(double x1, double y1, double x2, double y2, double x3, double y3); @@ -107,14 +107,31 @@ getScaleOffsetForFormat(float min, float max, bool novalue, OpenVDS::VolumeDataC int main(int argc, char *argv[]) { + cxxopts::Options options("VDSFileCreate", "Create synthetic vds file"); + std::string vdsFileName; + options.add_option("", "", "vdsfile", "Output VDS file name.", cxxopts::value(vdsFileName), ""); + + if (argc == 1) { + std::cout << options.help(); + return EXIT_SUCCESS; + } + + try { + options.parse(argc, argv); + } + catch(cxxopts::OptionParseException &e) { + fmt::print(stderr, "{}", e.what()); + return EXIT_FAILURE; + } + int32_t samplesX = 500; int32_t samplesY = 800; int32_t samplesZ = 800; std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); - createNoLODVDS(samplesX, samplesY, samplesZ); - //createLODVDS(samplesX, samplesY, samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels_2); + createNoLODVDS(vdsFileName, samplesX, samplesY, samplesZ); + //createLODVDS(vdsFileName, samplesX, samplesY, samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels_3); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); long elapsed = std::chrono::duration_cast(end - begin).count(); @@ -125,7 +142,7 @@ main(int argc, char *argv[]) { return EXIT_SUCCESS; } -void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ) { +void createNoLODVDS(const std::string &vdsFileName, int32_t samplesX, int32_t samplesY, int32_t samplesZ) { OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_64; @@ -154,7 +171,7 @@ void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ) { OpenVDS::VolumeDataChannelDescriptor::Default, -999.25f, intScale, intOffset); //OpenVDS::InMemoryOpenOptions options; - OpenVDS::VDSFileOpenOptions options("/tmp/createCPP_bis.vds"); + OpenVDS::VDSFileOpenOptions options(vdsFileName); OpenVDS::Error error; OpenVDS::MetadataContainer metadataContainer; @@ -188,6 +205,12 @@ void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ) { OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, 0, channel, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); //ASSERT_TRUE(pageAccessor); + double distMax = distance3D(0, 0, 0, samplesX, samplesY, samplesZ); + double cycles = M_PI * 2 * 6; + double midX = samplesX / 2.f; + double midY = samplesY / 2.f; + double midZ = samplesZ / 2.f; + int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); for (int i = 0; i < chunkCount; i++) @@ -206,16 +229,22 @@ void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ) { auto output = static_cast(buffer); for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) - for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) - for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) - { - OpenVDS::IntVector<3> localOutIndex(iDim0, iDim1, iDim2); - OpenVDS::IntVector<3> vox = outputIndexer.LocalIndexToVoxelIndex(localOutIndex); - float value = (float) ((vox[0] + vox[1] + vox[2])) / numSamples[0]; - value = rangeMin + 2.f * value; - int dataPos = outputIndexer.LocalIndexToDataIndex(localOutIndex); - output[dataPos] = value; + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) + { + OpenVDS::IntVector<3> localOutIndex(iDim0, iDim1, iDim2); + OpenVDS::IntVector<3> vox = outputIndexer.LocalIndexToVoxelIndex(localOutIndex); + float value = 0.f; + double dist = 0.; + if (vox[0] >= midX) { + dist = distance2D(midY, midZ, vox[1], vox[2]); + } else { + dist = distance3D(midX, midY, midZ, vox[0], vox[1], vox[2]); } + value = (float) sin((dist * cycles) / distMax); + int dataPos = outputIndexer.LocalIndexToDataIndex(localOutIndex); + output[dataPos] = value; + } page->Release(); } @@ -228,7 +257,7 @@ void createNoLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ) { OpenVDS::Close(vds); } -void createLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels lodLevel) { +void createLODVDS(const std::string &vdsFileName, int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS::VolumeDataLayoutDescriptor::LODLevels lodLevel) { double distMax = distance3D(0, 0, 0, samplesX, samplesY, samplesZ); double cycles = M_PI * 2 * 6; @@ -238,7 +267,7 @@ void createLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS: OpenVDS::VolumeDataChannelDescriptor::Format format = OpenVDS::VolumeDataChannelDescriptor::Format_R32; - auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_64; + auto brickSize = OpenVDS::VolumeDataLayoutDescriptor::BrickSize_256; int negativeMargin = 4; int positiveMargin = 4; int brickSize2DMultiplier = 4; @@ -265,7 +294,7 @@ void createLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS: OpenVDS::VolumeDataChannelDescriptor::Default, -999.25f, intScale, intOffset); //OpenVDS::InMemoryOpenOptions options; - OpenVDS::VDSFileOpenOptions options("/tmp/createCPP_LOD.vds"); + OpenVDS::VDSFileOpenOptions options(vdsFileName); OpenVDS::Error error; OpenVDS::MetadataContainer metadataContainer; @@ -303,7 +332,6 @@ void createLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS: int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); //OpenVDS::VolumeDataChannelDescriptor::Format format = layout->GetChannelFormat(channel); - int posMax = -1; for (int i = 0; i < chunkCount; i++) { OpenVDS::VolumeDataPage *page = pageAccessor->CreatePage(i); OpenVDS::VolumeIndexer3D outputIndexer(page, 0, lod, OpenVDS::Dimensions_012, layout); @@ -338,13 +366,11 @@ void createLODVDS(int32_t samplesX, int32_t samplesY, int32_t samplesZ, OpenVDS: value = (float) sin((dist * cycles) / distMax); int dataPos = outputIndexer.LocalIndexToDataIndex(localIndex); - posMax = dataPos > posMax ? dataPos : posMax; output[dataPos] = value; } page->Release(); } - std::cout << "For LOD " << lod << " position Max is " << posMax << std::endl; pageAccessor->Commit(); pageAccessor->SetMaxPages(0); -- GitLab From 1dce00c872e2c8bde05afb1b58f4fbfe5eca3a2e Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Tue, 27 Apr 2021 15:58:38 +0200 Subject: [PATCH 020/194] Bug fix : manages option for 2D Lod Adds demo for sliced cube (w/wout LOD) --- java/cpp/src/OpenVDSJava.cpp | 15 +- java/java/demo/CreateVDSSliceNoLOD.java | 315 +++++++++++++++++++++ java/java/demo/CreateVDSSliceWithLOD.java | 326 ++++++++++++++++++++++ java/java/demo/CreateVDSWithLOD.java | 10 +- 4 files changed, 657 insertions(+), 9 deletions(-) create mode 100644 java/java/demo/CreateVDSSliceNoLOD.java create mode 100644 java/java/demo/CreateVDSSliceWithLOD.java diff --git a/java/cpp/src/OpenVDSJava.cpp b/java/cpp/src/OpenVDSJava.cpp index 47afa85e..40dc5d23 100644 --- a/java/cpp/src/OpenVDSJava.cpp +++ b/java/cpp/src/OpenVDSJava.cpp @@ -300,12 +300,19 @@ getDescriptor(JNIEnv *env, jobject obj) int brickSize2DMultiplier = env->CallIntMethod(obj, env->GetMethodID(obj_class, "getBrickSizeMultiplier2D", "()I")); auto lodLevels = getLODLevels(env, obj); - int fullResolutionDimension = env->CallBooleanMethod(obj, env->GetMethodID(obj_class, "isForceFullResolutionDimension", "()Z")); - - int options = (env->CallBooleanMethod(obj, env->GetMethodID(obj_class, "isCreate2DLODs", "()Z")) << 1); + bool forceFullResolutionDimension = env->CallBooleanMethod(obj, env->GetMethodID(obj_class, "isForceFullResolutionDimension", "()Z")); + int fullResDim = env->CallIntMethod(obj, env->GetMethodID(obj_class, "getFullResolutionDimension", "()I")); + bool lod2D = env->CallBooleanMethod(obj, env->GetMethodID(obj_class, "isCreate2DLODs", "()Z")); + int optionsP = OpenVDS::VolumeDataLayoutDescriptor::Options::Options_None; + if (lod2D) { + optionsP |= OpenVDS::VolumeDataLayoutDescriptor::Options::Options_Create2DLODs; + } + if (forceFullResolutionDimension) { + optionsP |= OpenVDS::VolumeDataLayoutDescriptor::Options::Options_ForceFullResolutionDimension; + } return OpenVDS::VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, brickSize2DMultiplier, - lodLevels, (OpenVDS::VolumeDataLayoutDescriptor::Options) options, fullResolutionDimension); + lodLevels, (OpenVDS::VolumeDataLayoutDescriptor::Options) optionsP, fullResDim); } static jlong diff --git a/java/java/demo/CreateVDSSliceNoLOD.java b/java/java/demo/CreateVDSSliceNoLOD.java new file mode 100644 index 00000000..d2daf1b9 --- /dev/null +++ b/java/java/demo/CreateVDSSliceNoLOD.java @@ -0,0 +1,315 @@ +import org.opengroup.openvds.*; + +import java.io.File; +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.DoubleSummaryStatistics; +import java.util.List; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; + +public class CreateVDSSliceNoLOD { + + // usage : CreateVDSWithLOD n /path/to/file + // where n is the LOD level wanted + public static void main(String[] args) { + try { + if (!checkParams(args)) { + System.out.println("Bad params, usage : /path/to/file"); + System.out.println("where path must be a valid non existing file path"); + } + else { + Instant start = Instant.now(); + process(args[0]); + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } + } + catch (Throwable t) { + System.out.println(); + t.printStackTrace(); + } + } + + private static boolean checkParams(String[] args) { + if (args == null || args.length != 1) { + return false; + } + String path = args[0]; + File file = new File(path); + try { + file.getCanonicalPath(); + } + catch (IOException e) { + System.err.println("VDS File path is invalid !"); + return false; + } + if (!path.endsWith(".vds")) { + System.err.println("VDS File path must have vds extension !"); + return false; + } + if (file.exists()) { + System.err.println("VDS File already exists !"); + return false; + } + return true; + } + + static void process(String vdsFilePath) throws Exception { + + int samplesX = 500; // time + int samplesY = 400; // XL + int samplesZ = 400; // IL + VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; + + double sizeX = samplesX; + double sizeY = samplesY; + double sizeZ = samplesZ; + + double distMax = distance3D(0, 0, 0, sizeX, sizeY, sizeZ); + double cycles = Math.PI * 2 * 20; + double midX = samplesX / 2f; + double midY = samplesY / 2f; + double midZ = samplesZ / 2f; + + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_64; + int negativeMargin = 0; + int positiveMargin = 0; + int brickSize2DMultiplier = 4; + + VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.LOD_LEVELS_NONE; + + //VolumeDataLayoutDescriptor.Options layoutOptions = VolumeDataLayoutDescriptor.Options.NONE; + VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, false,false,0); + + List axisDescriptors = new ArrayList<>(); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "s", 0.0f,4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1000f, 1000f + samplesY - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); + + List channelDescriptors = new ArrayList<>(); + + float rangeMin = -1f; + float rangeMax = 1f; + float[] scaleOffset = getScaleOffsetForFormat(rangeMin, rangeMax, true, format); + + VolumeDataChannelDescriptor channelDescriptor = new VolumeDataChannelDescriptor(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", + "", + rangeMin, // range min + rangeMax, // range max + VolumeDataMapping.DIRECT, // mapping + 1, // mapped value count + false, // is discrete + true, // is renderable + false, // allow lossy compression + false, // use zip for lossless compresion + true, // use no value + -999.25f, // no value + scaleOffset[0], // integer scale + scaleOffset[1]); // integer offset + channelDescriptors.add(channelDescriptor); + + + //OpenVDS::InMemoryOpenOptions options; + VDSFileOpenOptions options = new VDSFileOpenOptions(vdsFilePath); + VdsError error; + + MetadataContainer metadataContainer = new MetadataContainer(); + metadataContainer.setMetadataString("categoryString", "String", "Sliced"); + //metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); + + VdsHandle vds = OpenVDS.create(options, layoutDescriptor, + axisDescriptors.toArray(new VolumeDataAxisDescriptor[0]), + channelDescriptors.toArray(new VolumeDataChannelDescriptor[0]), metadataContainer); + + + VolumeDataLayout layout = vds.getLayout(); + //ASSERT_TRUE(layout); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + + int dimensionality = layout.getDimensionality(); + long timeRead = 0L; + long timeWrite = 0L; + long timeVolIndex = 0L; + + int lodCount = lodLevels.ordinal(); + + int[] localIndex = new int[2]; + int[] voxelPos = new int[3]; + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_01.ordinal(), // dimension ND + 0, // lod + channel, // channel + 200, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + + //ASSERT_TRUE(pageAccessor); + int paLOD = pageAccessor.getLOD(); + int paCI = pageAccessor.getChannelIndex(); + int[] paNumSamples = pageAccessor.getNumSamples(); + + int chunkCount = (int) pageAccessor.getChunkCount(); + System.out.println("LOD : " + 0 + " Chunk count : " + chunkCount); + + for (int i = 0; i < chunkCount; i++) { + + long time_1 = System.currentTimeMillis(); + System.out.print("Page " + (i + 1) + " / " + chunkCount); + VolumeDataPage page = pageAccessor.createPage(i); + + VolumeIndexer2D outputIndexer = new VolumeIndexer2D(page, 0, 0, DimensionsND.DIMENSIONS_01.ordinal(), layout); + + int[] numSamplesChunk = new int[3]; + int[] numSamplesDB = new int[3]; + + for (int j = 0; j < 3; j++) { + numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); + numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); + } + System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); + System.out.print("\tDimensions DataBlock : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); + + page.getMinMax(chunkMin, chunkMax); + + System.out.print("\tCoords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[2] + "/" + chunkMax[2]); + int chunkSizeY = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + + // get pitch and allocate buffer size + //page.getPitch(pitch); + //float[] output = new float[page.getAllocatedBufferSize()]; + + // or read buffer of page + float[] output = page.readFloatBuffer(pitch); + + DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); + DoubleSummaryStatistics stats = ds.summaryStatistics(); + System.out.print( " Page Buffer Size : " + output.length + " / [" + stats.getMin() + "," + stats.getMax() + "]"); + // dimension of buffer + System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); + + int dimPitch = pitch[dimensionality - 1] * (chunkMax[dimensionality - 1] - chunkMin[dimensionality - 1]); + + long time_2 = System.currentTimeMillis(); + + int[] numSamples = numSamplesChunk; + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) { + voxelPos[2] = chunkMax[2]; + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) { + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + localIndex[0] = iDim0; + localIndex[1] = iDim1; + //localIndex[2] = iDim2; + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); + for (int vp = 0; vp < 2; ++vp) { + voxelPos[vp] = voxelIndex[vp]; + } + + + float value = 0f; + double dist = 0; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = ((float)iDim0 / (float)samplesX);// (float) Math.sin((dist * cycles) / distMax); + + int iPos = outputIndexer.localIndexToDataIndex(localIndex); + output[iPos] = value; + } + } + } + + // write buffer then release page + long time_3 = System.currentTimeMillis(); + page.writeFloatBuffer(output, pitch); + page.pageRelease(); + long time_4 = System.currentTimeMillis(); + + timeRead += (time_2 - time_1); + timeVolIndex += (time_3 - time_2); + timeWrite += (time_4 - time_3); + } + + pageAccessor.commit(); + pageAccessor.setMaxPages(0); + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + + displayStatistics(timeRead, timeVolIndex, timeWrite); + + vds.close(); // equivalent to OpenVDS.close(vds); ? + System.out.println("VDS closed"); + } + + private static void displayStatistics(long timeRead, long timeVolIndex, long timeWrite) { + long totalTime = timeRead + timeVolIndex + timeWrite; + float pctRead = (timeRead * 100f) / (float)totalTime; + float pctVolIndex = (timeVolIndex * 100f) / (float)totalTime; + float pctWrite = (timeWrite * 100f) / (float)totalTime; + + System.out.println("Read took " + timeRead + "ms : " + pctRead + "%"); + System.out.println("Write took " + timeWrite + "ms : " + pctWrite + "%"); + System.out.println("Index compute took " + timeVolIndex + "ms : " + pctVolIndex + "%"); + } + + private static double distance2D(double x1, double y1, double x2, double y2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + return Math.sqrt((diffX * diffX) + (diffY * diffY)); + } + + private static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + double diffZ = z2 - z1; + return Math.sqrt((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); + } + + static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { + float res[] = new float[] {1f, 0f}; + float noValueCmp = useNoValue ? 1f : 0f; + switch (format) { + case FORMAT_U8: + res[0] = 1.f / (255.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_U16: + res[0] = 1.f / (65535.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_R32: + case FORMAT_U32: + case FORMAT_R64: + case FORMAT_U64: + case FORMAT_1BIT: + case FORMAT_ANY: + res[0] = 1.0f; + res[1] = 0.0f; + } + return res; + } + +} diff --git a/java/java/demo/CreateVDSSliceWithLOD.java b/java/java/demo/CreateVDSSliceWithLOD.java new file mode 100644 index 00000000..164f2c4c --- /dev/null +++ b/java/java/demo/CreateVDSSliceWithLOD.java @@ -0,0 +1,326 @@ +import org.opengroup.openvds.*; + +import java.io.File; +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.DoubleSummaryStatistics; +import java.util.List; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; + +public class CreateVDSSliceWithLOD { + + // usage : CreateVDSWithLOD n /path/to/file + // where n is the LOD level wanted + public static void main(String[] args) { + try { + if (!checkParams(args)) { + System.out.println("Bad params, usage : n /path/to/file"); + System.out.println("where n is the LOD level wanted (0 <= lod <= 12), path must be a valid non existing file path"); + } + else { + Instant start = Instant.now(); + process(Integer.parseInt(args[0]), args[1]); + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } + } + catch (Throwable t) { + System.out.println(); + t.printStackTrace(); + } + } + + private static boolean checkParams(String[] args) { + if (args == null || args.length != 2) { + return false; + } + try { + Integer lod = Integer.parseInt(args[0]); + if (lod < 0 || lod > 12) { + return false; + } + } + catch (NumberFormatException nfe) { + return false; + } + String path = args[1]; + File file = new File(path); + try { + file.getCanonicalPath(); + } + catch (IOException e) { + System.err.println("VDS File path is invalid !"); + return false; + } + if (!path.endsWith(".vds")) { + System.err.println("VDS File path must have vds extension !"); + return false; + } + if (file.exists()) { + System.err.println("VDS File already exists !"); + return false; + } + return true; + } + + static void process(int lodParam, String vdsFilePath) throws Exception { + + int samplesX = 500; // time + int samplesY = 300; // XL + int samplesZ = 300; // IL + VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; + + double sizeX = samplesX; + double sizeY = samplesY; + double sizeZ = samplesZ; + + double distMax = distance3D(0, 0, 0, sizeX, sizeY, sizeZ); + double cycles = Math.PI * 2 * 20; + double midX = samplesX / 2f; + double midY = samplesY / 2f; + double midZ = samplesZ / 2f; + + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_128; + int negativeMargin = 0; + int positiveMargin = 0; + int brickSize2DMultiplier = 2; + + VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.values()[lodParam]; + + //VolumeDataLayoutDescriptor.Options layoutOptions = VolumeDataLayoutDescriptor.Options.NONE; + VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, true,false,0); + + List axisDescriptors = new ArrayList<>(); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "s", 0.0f,4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1000f, 1000f + samplesY - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); + + List channelDescriptors = new ArrayList<>(); + + float rangeMin = -1f; + float rangeMax = 1f; + float[] scaleOffset = getScaleOffsetForFormat(rangeMin, rangeMax, true, format); + + VolumeDataChannelDescriptor channelDescriptor = new VolumeDataChannelDescriptor(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", + "", + rangeMin, // range min + rangeMax, // range max + VolumeDataMapping.DIRECT, // mapping + 1, // mapped value count + false, // is discrete + true, // is renderable + false, // allow lossy compression + false, // use zip for lossless compresion + true, // use no value + -999.25f, // no value + scaleOffset[0], // integer scale + scaleOffset[1]); // integer offset + channelDescriptors.add(channelDescriptor); + + + //OpenVDS::InMemoryOpenOptions options; + VDSFileOpenOptions options = new VDSFileOpenOptions(vdsFilePath); + VdsError error; + + MetadataContainer metadataContainer = new MetadataContainer(); + metadataContainer.setMetadataString("categoryString", "String", "Sliced LOD"); + //metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); + + VdsHandle vds = OpenVDS.create(options, layoutDescriptor, + axisDescriptors.toArray(new VolumeDataAxisDescriptor[0]), + channelDescriptors.toArray(new VolumeDataChannelDescriptor[0]), metadataContainer); + + + VolumeDataLayout layout = vds.getLayout(); + //ASSERT_TRUE(layout); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + + int dimensionality = layout.getDimensionality(); + long timeRead = 0L; + long timeWrite = 0L; + long timeVolIndex = 0L; + + int lodCount = lodLevels.ordinal(); + + int[] localIndex = new int[2]; + int[] voxelPos = new int[3]; + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + + for (int lod = 0 ; lod <= lodCount ; ++lod) { + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_01.ordinal(), // dimension ND + lod, // lod + channel, // channel + 200, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + + //ASSERT_TRUE(pageAccessor); + int paLOD = pageAccessor.getLOD(); + int paCI = pageAccessor.getChannelIndex(); + int[] paNumSamples = pageAccessor.getNumSamples(); + + int chunkCount = (int) pageAccessor.getChunkCount(); + System.out.println("LOD : " + lod + " Chunk count : " + chunkCount); + + for (int i = 0; i < chunkCount; i++) { + + long time_1 = System.currentTimeMillis(); + + VolumeDataPage page = pageAccessor.createPage(i); + System.out.print("LOD : " + lod + " / Page " + (i + 1) + " / " + chunkCount); + + VolumeIndexer2D outputIndexer = new VolumeIndexer2D(page, 0, lod, DimensionsND.DIMENSIONS_01.ordinal(), layout); + float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); + + int[] numSamplesChunk = new int[3]; + int[] numSamplesDB = new int[3]; + + for (int j = 0; j < 3; j++) { + numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); + numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); + } + System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); + System.out.print("\tDimensions DataBlock : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); + + page.getMinMax(chunkMin, chunkMax); + + System.out.print("\tCoords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[2] + "/" + chunkMax[2]); + int chunkSizeY = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + + // get pitch and allocate buffer size + //page.getPitch(pitch); + //float[] output = new float[page.getAllocatedBufferSize()]; + + // or read buffer of page + float[] output = page.readFloatBuffer(pitch); + + DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); + DoubleSummaryStatistics stats = ds.summaryStatistics(); + System.out.print( " Page Buffer Size : " + output.length + " / [" + stats.getMin() + "," + stats.getMax() + "]"); + // dimension of buffer + System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); + + int dimPitch = pitch[dimensionality - 1] * (chunkMax[dimensionality - 1] - chunkMin[dimensionality - 1]); + + long time_2 = System.currentTimeMillis(); + + int[] numSamples = numSamplesChunk; + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) { + voxelPos[2] = iDim2; + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) { + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + localIndex[0] = iDim0; + localIndex[1] = iDim1; + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); + for (int vp = 0; vp < 2; ++vp) { + voxelPos[vp] = voxelIndex[vp]; + } + + float value = 0f; + double dist = 0; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = (float) Math.sin((dist * cycles) / distMax); + + int iPos = outputIndexer.localIndexToDataIndex(localIndex); + output[iPos] = value; + } + } + } + + // write buffer then release page + long time_3 = System.currentTimeMillis(); + page.writeFloatBuffer(output, pitch); + page.pageRelease(); + long time_4 = System.currentTimeMillis(); + + timeRead += (time_2 - time_1); + timeVolIndex += (time_3 - time_2); + timeWrite += (time_4 - time_3); + } + + pageAccessor.commit(); + pageAccessor.setMaxPages(0); + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + } + + displayStatistics(timeRead, timeVolIndex, timeWrite); + + vds.close(); // equivalent to OpenVDS.close(vds); ? + System.out.println("VDS closed"); + } + + private static void displayStatistics(long timeRead, long timeVolIndex, long timeWrite) { + long totalTime = timeRead + timeVolIndex + timeWrite; + float pctRead = (timeRead * 100f) / (float)totalTime; + float pctVolIndex = (timeVolIndex * 100f) / (float)totalTime; + float pctWrite = (timeWrite * 100f) / (float)totalTime; + + System.out.println("Read took " + timeRead + "ms : " + pctRead + "%"); + System.out.println("Write took " + timeWrite + "ms : " + pctWrite + "%"); + System.out.println("Index compute took " + timeVolIndex + "ms : " + pctVolIndex + "%"); + } + + private static double distance2D(double x1, double y1, double x2, double y2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + return Math.sqrt((diffX * diffX) + (diffY * diffY)); + } + + private static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + double diffZ = z2 - z1; + return Math.sqrt((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); + } + + static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { + float res[] = new float[] {1f, 0f}; + float noValueCmp = useNoValue ? 1f : 0f; + switch (format) { + case FORMAT_U8: + res[0] = 1.f / (255.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_U16: + res[0] = 1.f / (65535.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_R32: + case FORMAT_U32: + case FORMAT_R64: + case FORMAT_U64: + case FORMAT_1BIT: + case FORMAT_ANY: + res[0] = 1.0f; + res[1] = 0.0f; + } + return res; + } + +} diff --git a/java/java/demo/CreateVDSWithLOD.java b/java/java/demo/CreateVDSWithLOD.java index b10b9130..b1244346 100644 --- a/java/java/demo/CreateVDSWithLOD.java +++ b/java/java/demo/CreateVDSWithLOD.java @@ -73,9 +73,9 @@ public class CreateVDSWithLOD { static void process(int lodParam, String vdsFilePath) throws Exception { - int samplesX = 1500; // time - int samplesY = 2000; // XL - int samplesZ = 2000; // IL + int samplesX = 1000; // time + int samplesY = 500; // XL + int samplesZ = 500; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; double sizeX = samplesX; @@ -100,7 +100,7 @@ public class CreateVDSWithLOD { brickSize2DMultiplier, lodLevels, false,false,0); List axisDescriptors = new ArrayList<>(); - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "ms", 0.0f,4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "s", 0.0f,4.f)); axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1000f, 1000f + samplesY - 1f)); axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); @@ -180,7 +180,7 @@ public class CreateVDSWithLOD { DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND lod, // lod channel, // channel - 100, // max pages + 200, // max pages VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode -- GitLab From df283247821743d2058321a771918b766606685f Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Fri, 30 Apr 2021 16:44:40 +0200 Subject: [PATCH 021/194] Main with Sliced LOD on AWS --- java/java/demo/CreateVDSSliceLODOnCloud.java | 314 +++++++++++++++++++ java/java/demo/CreateVDSSliceNoLOD.java | 4 +- java/java/demo/CreateVDSWithLOD.java | 47 ++- 3 files changed, 335 insertions(+), 30 deletions(-) create mode 100644 java/java/demo/CreateVDSSliceLODOnCloud.java diff --git a/java/java/demo/CreateVDSSliceLODOnCloud.java b/java/java/demo/CreateVDSSliceLODOnCloud.java new file mode 100644 index 00000000..efb0e7ac --- /dev/null +++ b/java/java/demo/CreateVDSSliceLODOnCloud.java @@ -0,0 +1,314 @@ +import org.opengroup.openvds.*; + +import java.io.File; +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.DoubleSummaryStatistics; +import java.util.List; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; + +public class CreateVDSSliceLODOnCloud { + + // usage : CreateVDSWithLOD n /path/to/file + // where n is the LOD level wanted + public static void main(String[] args) { + try { + if (!checkParams(args)) { + System.out.println("Bad params, usage : n /path/to/file"); + System.out.println("where n is the LOD level wanted (0 <= lod <= 12), path must be a valid non existing file path"); + } + else { + Instant start = Instant.now(); + process(Integer.parseInt(args[0])); + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } + } + catch (Throwable t) { + System.out.println(); + t.printStackTrace(); + } + } + + private static boolean checkParams(String[] args) { + if (args == null || args.length != 1) { + return false; + } + try { + Integer lod = Integer.parseInt(args[0]); + if (lod < 0 || lod > 12) { + return false; + } + } + catch (NumberFormatException nfe) { + return false; + } + return true; + } + + static void process(int lodParam) throws Exception { + + int samplesX = 800; // time + int samplesY = 600; // XL + int samplesZ = 600; // IL + VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; + + double sizeX = samplesX; + double sizeY = samplesY; + double sizeZ = samplesZ; + + double distMax = distance3D(0, 0, 0, sizeX, sizeY, sizeZ); + double cycles = Math.PI * 2 * 20; + double midX = samplesX / 2f; + double midY = samplesY / 2f; + double midZ = samplesZ / 2f; + + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_512; + int negativeMargin = 0; + int positiveMargin = 0; + int brickSize2DMultiplier = 2; + + VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.values()[lodParam]; + + //VolumeDataLayoutDescriptor.Options layoutOptions = VolumeDataLayoutDescriptor.Options.NONE; + VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, true,false,0); + + List axisDescriptors = new ArrayList<>(); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "s", 0.0f,4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1000f, 1000f + samplesY - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); + + List channelDescriptors = new ArrayList<>(); + + float rangeMin = -1f; + float rangeMax = 1f; + float[] scaleOffset = getScaleOffsetForFormat(rangeMin, rangeMax, true, format); + + VolumeDataChannelDescriptor channelDescriptor = new VolumeDataChannelDescriptor(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", + "", + rangeMin, // range min + rangeMax, // range max + VolumeDataMapping.DIRECT, // mapping + 1, // mapped value count + false, // is discrete + true, // is renderable + false, // allow lossy compression + false, // use zip for lossless compresion + true, // use no value + -999.25f, // no value + scaleOffset[0], // integer scale + scaleOffset[1]); // integer offset + channelDescriptors.add(channelDescriptor); + + + //OpenVDS::InMemoryOpenOptions options; + // options AWS + String pBucket = "openvds-test-int"; // the bucket of the VDS + String pKey = ""; // the key prefix of the VDS ? + String pRegion = "eu-west-3"; // the region of the bucket of the VDS + String pEndpointOverride = ""; // This parameter allows to override the endpoint url + AWSOpenOptions optionsAWS = new AWSOpenOptions(pBucket, pKey, pRegion, pEndpointOverride); + optionsAWS.accessKeyId = ""; // ? + optionsAWS.sessionToken = ""; // ? + + MetadataContainer metadataContainer = new MetadataContainer(); + metadataContainer.setMetadataString("Infos", "Creation", "Sliced LOD 800x800x600 Brick 512"); + + VdsHandle vds = OpenVDS.create(optionsAWS, layoutDescriptor, + axisDescriptors.toArray(new VolumeDataAxisDescriptor[0]), + channelDescriptors.toArray(new VolumeDataChannelDescriptor[0]), metadataContainer); + + + VolumeDataLayout layout = vds.getLayout(); + //ASSERT_TRUE(layout); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + + int dimensionality = layout.getDimensionality(); + long timeRead = 0L; + long timeWrite = 0L; + long timeVolIndex = 0L; + + int lodCount = lodLevels.ordinal(); + + int[] localIndex = new int[2]; + int[] voxelPos = new int[3]; + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + + for (int lod = 0 ; lod <= lodCount ; ++lod) { + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_01.ordinal(), // dimension ND + lod, // lod + channel, // channel + 200, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + + //ASSERT_TRUE(pageAccessor); + int paLOD = pageAccessor.getLOD(); + int paCI = pageAccessor.getChannelIndex(); + int[] paNumSamples = pageAccessor.getNumSamples(); + + int chunkCount = (int) pageAccessor.getChunkCount(); + System.out.println("LOD : " + lod + " Chunk count : " + chunkCount); + + for (int i = 0; i < chunkCount; i++) { + + long time_1 = System.currentTimeMillis(); + + VolumeDataPage page = pageAccessor.createPage(i); + System.out.print("LOD : " + lod + " / Page " + (i + 1) + " / " + chunkCount); + + VolumeIndexer2D outputIndexer = new VolumeIndexer2D(page, 0, lod, DimensionsND.DIMENSIONS_01.ordinal(), layout); + float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); + + int[] numSamplesChunk = new int[3]; + int[] numSamplesDB = new int[3]; + + for (int j = 0; j < 3; j++) { + numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); + numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); + } + System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); + System.out.print("\tDimensions DataBlock : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); + + page.getMinMax(chunkMin, chunkMax); + + System.out.print("\tCoords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[2] + "/" + chunkMax[2]); + int chunkSizeY = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + + // get pitch and allocate buffer size + //page.getPitch(pitch); + //float[] output = new float[page.getAllocatedBufferSize()]; + + // or read buffer of page + float[] output = page.readFloatBuffer(pitch); + + DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); + DoubleSummaryStatistics stats = ds.summaryStatistics(); + System.out.print( " Page Buffer Size : " + output.length + " / [" + stats.getMin() + "," + stats.getMax() + "]"); + // dimension of buffer + System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); + + int dimPitch = pitch[dimensionality - 1] * (chunkMax[dimensionality - 1] - chunkMin[dimensionality - 1]); + + long time_2 = System.currentTimeMillis(); + + int[] numSamples = numSamplesChunk; + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) { + voxelPos[2] = iDim2; + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) { + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + localIndex[0] = iDim0; + localIndex[1] = iDim1; + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); + for (int vp = 0; vp < 2; ++vp) { + voxelPos[vp] = voxelIndex[vp]; + } + + float value = 0f; + double dist = 0; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = (float) Math.sin((dist * cycles) / distMax); + + int iPos = outputIndexer.localIndexToDataIndex(localIndex); + output[iPos] = value; + } + } + } + + // write buffer then release page + long time_3 = System.currentTimeMillis(); + page.writeFloatBuffer(output, pitch); + page.pageRelease(); + long time_4 = System.currentTimeMillis(); + + timeRead += (time_2 - time_1); + timeVolIndex += (time_3 - time_2); + timeWrite += (time_4 - time_3); + } + + pageAccessor.commit(); + pageAccessor.setMaxPages(0); + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + } + + displayStatistics(timeRead, timeVolIndex, timeWrite); + + vds.close(); // equivalent to OpenVDS.close(vds); ? + System.out.println("VDS closed"); + } + + private static void displayStatistics(long timeRead, long timeVolIndex, long timeWrite) { + long totalTime = timeRead + timeVolIndex + timeWrite; + float pctRead = (timeRead * 100f) / (float)totalTime; + float pctVolIndex = (timeVolIndex * 100f) / (float)totalTime; + float pctWrite = (timeWrite * 100f) / (float)totalTime; + + System.out.println("Read took " + timeRead + "ms : " + pctRead + "%"); + System.out.println("Write took " + timeWrite + "ms : " + pctWrite + "%"); + System.out.println("Index compute took " + timeVolIndex + "ms : " + pctVolIndex + "%"); + } + + private static double distance2D(double x1, double y1, double x2, double y2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + return Math.sqrt((diffX * diffX) + (diffY * diffY)); + } + + private static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + double diffZ = z2 - z1; + return Math.sqrt((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); + } + + static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { + float res[] = new float[] {1f, 0f}; + float noValueCmp = useNoValue ? 1f : 0f; + switch (format) { + case FORMAT_U8: + res[0] = 1.f / (255.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_U16: + res[0] = 1.f / (65535.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_R32: + case FORMAT_U32: + case FORMAT_R64: + case FORMAT_U64: + case FORMAT_1BIT: + case FORMAT_ANY: + res[0] = 1.0f; + res[1] = 0.0f; + } + return res; + } + +} diff --git a/java/java/demo/CreateVDSSliceNoLOD.java b/java/java/demo/CreateVDSSliceNoLOD.java index d2daf1b9..e9ee0fa2 100644 --- a/java/java/demo/CreateVDSSliceNoLOD.java +++ b/java/java/demo/CreateVDSSliceNoLOD.java @@ -65,8 +65,8 @@ public class CreateVDSSliceNoLOD { static void process(String vdsFilePath) throws Exception { int samplesX = 500; // time - int samplesY = 400; // XL - int samplesZ = 400; // IL + int samplesY = 800; // XL + int samplesZ = 800; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; double sizeX = samplesX; diff --git a/java/java/demo/CreateVDSWithLOD.java b/java/java/demo/CreateVDSWithLOD.java index b1244346..0eaf6b35 100644 --- a/java/java/demo/CreateVDSWithLOD.java +++ b/java/java/demo/CreateVDSWithLOD.java @@ -73,9 +73,9 @@ public class CreateVDSWithLOD { static void process(int lodParam, String vdsFilePath) throws Exception { - int samplesX = 1000; // time - int samplesY = 500; // XL - int samplesZ = 500; // IL + int samplesX = 3000; // time + int samplesY = 5000; // XL + int samplesZ = 5000; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; double sizeX = samplesX; @@ -100,7 +100,7 @@ public class CreateVDSWithLOD { brickSize2DMultiplier, lodLevels, false,false,0); List axisDescriptors = new ArrayList<>(); - axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "s", 0.0f,4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "s", 0.0f,6.0f)); axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1000f, 1000f + samplesY - 1f)); axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); @@ -133,19 +133,7 @@ public class CreateVDSWithLOD { VdsError error; MetadataContainer metadataContainer = new MetadataContainer(); - metadataContainer.setMetadataInt("categoryInt", "Int", 123); - metadataContainer.setMetadataIntVector2("categoryInt", "IntVector2", new int[] {45, 78}); - metadataContainer.setMetadataIntVector3("categoryInt", "IntVector3", new int[] {45, 78, 72}); - metadataContainer.setMetadataIntVector4("categoryInt", "IntVector4", new int[] {45, 78, 72, 84}); - metadataContainer.setMetadataFloat("categoryFloat", "Float", 123.f); - metadataContainer.setMetadataFloatVector2("categoryFloat", "FloatVector2", new float[] {45.5f, 78.75f}); - metadataContainer.setMetadataFloatVector3("categoryFloat", "FloatVector3", new float[] {45.5f, 78.75f, 72.75f}); - metadataContainer.setMetadataFloatVector4("categoryFloat", "FloatVector4", new float[] {45.5f, 78.75f, 72.75f, 84.1f}); - metadataContainer.setMetadataDouble("categoryDouble", "Double", 123.); - metadataContainer.setMetadataDoubleVector2("categoryDouble", "DoubleVector2", new double[] {45.5, 78.75}); - metadataContainer.setMetadataDoubleVector3("categoryDouble", "DoubleVector3", new double[] {45.5, 78.75, 72.75}); - metadataContainer.setMetadataDoubleVector4("categoryDouble", "DoubleVector4", new double[] {45.5, 78.75, 72.75, 84.1}); - metadataContainer.setMetadataString("categoryString", "String", "Test string"); + metadataContainer.setMetadataString("categoryString", "String", "5K 5K 3K Volume B256 4 LOD"); //metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); VdsHandle vds = OpenVDS.create(options, layoutDescriptor, @@ -180,7 +168,7 @@ public class CreateVDSWithLOD { DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND lod, // lod channel, // channel - 200, // max pages + 100, // max pages VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode @@ -220,15 +208,15 @@ public class CreateVDSWithLOD { int chunkSizeZ = chunkMax[0] - chunkMin[0]; // get pitch and allocate buffer size - //page.getPitch(pitch); - //float[] output = new float[page.getAllocatedBufferSize()]; + page.getPitch(pitch); + float[] output = new float[page.getAllocatedBufferSize()]; // or read buffer of page - float[] output = page.readFloatBuffer(pitch); + //float[] output = page.readFloatBuffer(pitch); - DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); - DoubleSummaryStatistics stats = ds.summaryStatistics(); - System.out.print( " Page Buffer Size : " + output.length + " / [" + stats.getMin() + "," + stats.getMax() + "]"); + //DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); + //DoubleSummaryStatistics stats = ds.summaryStatistics(); + System.out.print( " Page Buffer Size : " + output.length + " ");/// [" + stats.getMin() + "," + stats.getMax() + "]"); // dimension of buffer System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); @@ -238,12 +226,13 @@ public class CreateVDSWithLOD { int[] numSamples = numSamplesChunk; - for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) - for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) { + localIndex[2] = iDim2; + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) { + localIndex[1] = iDim1; for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { localIndex[0] = iDim0; - localIndex[1] = iDim1; - localIndex[2] = iDim2; + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); for (int vp = 0; vp < 3; ++vp) { voxelPos[vp] = voxelIndex[vp]; @@ -261,6 +250,8 @@ public class CreateVDSWithLOD { int iPos = outputIndexer.localIndexToDataIndex(localIndex); output[iPos] = value; } + } + } // write buffer then release page long time_3 = System.currentTimeMillis(); -- GitLab From 62c5016e53bd3049c374ae69773d70676d6a5fd5 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Mon, 10 May 2021 17:13:53 +0200 Subject: [PATCH 022/194] Add get Upload error code on VolumeDataAccessManager --- java/cpp/src/VolumeDataAccessManager.cpp | 20 +++++++++++++++++++ .../openvds/VolumeDataAccessManager.java | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/java/cpp/src/VolumeDataAccessManager.cpp b/java/cpp/src/VolumeDataAccessManager.cpp index be2d348a..0f51597e 100644 --- a/java/cpp/src/VolumeDataAccessManager.cpp +++ b/java/cpp/src/VolumeDataAccessManager.cpp @@ -582,6 +582,26 @@ JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpUplo return 0; } +/* + * Class: org_opengroup_openvds_VolumeDataAccessManager + * Method: cpGetCurrentUploadErrorCode + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGetCurrentUploadErrorCode + (JNIEnv * env, jclass, jlong handle) +{ + try { + const char *pObjectID = nullptr; + const char *pErrorString = nullptr; + int32_t errorCode = 0; + + GetManager(handle)->GetCurrentUploadError(&pObjectID, &errorCode, &pErrorString); + return errorCode; + } + CATCH_EXCEPTIONS_FOR_JAVA; + return 0; +} + #ifdef __cplusplus } #endif diff --git a/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java b/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java index 1b0da345..255daf1c 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java @@ -142,6 +142,8 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { private static native int cpUploadErrorCount(long handle); + private static native int cpGetCurrentUploadErrorCode(long handle); + public VolumeDataAccessManager(long handle) { super(handle); } @@ -791,4 +793,8 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { public int uploadErrorCount() { return cpUploadErrorCount(_handle); } + + public int getCurrentUploadErrorCode() { + return cpGetCurrentUploadErrorCode(_handle); + } } -- GitLab From 6f3d6165a96844f0377af3935245d09bc76e83d6 Mon Sep 17 00:00:00 2001 From: Julien Lacoste Date: Tue, 25 May 2021 08:29:52 +0200 Subject: [PATCH 023/194] Add get Upload error code on VolumeDataAccessManager --- java/java/demo/CreateVDSSliceLODOnCloud.java | 70 ++- .../CreateVDSSliceMultiLayoutLODOnCloud.java | 515 ++++++++++++++++++ .../demo/CreateVDSWithLODMultipleLayout.java | 344 ++++++++++++ 3 files changed, 904 insertions(+), 25 deletions(-) create mode 100644 java/java/demo/CreateVDSSliceMultiLayoutLODOnCloud.java create mode 100644 java/java/demo/CreateVDSWithLODMultipleLayout.java diff --git a/java/java/demo/CreateVDSSliceLODOnCloud.java b/java/java/demo/CreateVDSSliceLODOnCloud.java index efb0e7ac..4468b717 100644 --- a/java/java/demo/CreateVDSSliceLODOnCloud.java +++ b/java/java/demo/CreateVDSSliceLODOnCloud.java @@ -17,8 +17,8 @@ public class CreateVDSSliceLODOnCloud { public static void main(String[] args) { try { if (!checkParams(args)) { - System.out.println("Bad params, usage : n /path/to/file"); - System.out.println("where n is the LOD level wanted (0 <= lod <= 12), path must be a valid non existing file path"); + System.out.println("Bad params, usage : n"); + System.out.println("where n is the LOD level wanted (0 <= lod <= 12)"); } else { Instant start = Instant.now(); @@ -56,9 +56,9 @@ public class CreateVDSSliceLODOnCloud { static void process(int lodParam) throws Exception { - int samplesX = 800; // time - int samplesY = 600; // XL - int samplesZ = 600; // IL + int samplesX = 300; // time + int samplesY = 500; // XL + int samplesZ = 500; // IL VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; double sizeX = samplesX; @@ -71,9 +71,9 @@ public class CreateVDSSliceLODOnCloud { double midY = samplesY / 2f; double midZ = samplesZ / 2f; - VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_512; - int negativeMargin = 0; - int positiveMargin = 0; + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_128; + int negativeMargin = 4; + int positiveMargin = 4; int brickSize2DMultiplier = 2; VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.values()[lodParam]; @@ -113,16 +113,26 @@ public class CreateVDSSliceLODOnCloud { //OpenVDS::InMemoryOpenOptions options; // options AWS - String pBucket = "openvds-test-int"; // the bucket of the VDS - String pKey = ""; // the key prefix of the VDS ? - String pRegion = "eu-west-3"; // the region of the bucket of the VDS +// String pBucket = "miniovaap"; // the bucket of the VDS +// String pKey = "CubeVDS_Test_NoLOD.vds"; // the key prefix of the VDS ? +// String pRegion = "eu-west-3"; // the region of the bucket of the VDS +// String pEndpointOverride = "https://webvr.int.com/"; // This parameter allows to override the endpoint url +// AWSOpenOptions optionsAWS = new AWSOpenOptions(pBucket, pKey, pRegion, pEndpointOverride); +// optionsAWS.accessKeyId = ""; // ? +// optionsAWS.secretKey = ""; +// optionsAWS.sessionToken = ""; // ? + + String pBucket = "intindexertest"; // the bucket of the VDS + String pKey = "java/CubeVDS_Test_NoLOD_B128.vds"; // the key prefix of the VDS ? + String pRegion = "us-east-2"; // the region of the bucket of the VDS String pEndpointOverride = ""; // This parameter allows to override the endpoint url AWSOpenOptions optionsAWS = new AWSOpenOptions(pBucket, pKey, pRegion, pEndpointOverride); optionsAWS.accessKeyId = ""; // ? + optionsAWS.secretKey = ""; optionsAWS.sessionToken = ""; // ? MetadataContainer metadataContainer = new MetadataContainer(); - metadataContainer.setMetadataString("Infos", "Creation", "Sliced LOD 800x800x600 Brick 512"); + metadataContainer.setMetadataString("Infos", "Creation", "Sliced LOD 500x500x300 Brick 32 (Margin 4)"); VdsHandle vds = OpenVDS.create(optionsAWS, layoutDescriptor, axisDescriptors.toArray(new VolumeDataAxisDescriptor[0]), @@ -143,7 +153,7 @@ public class CreateVDSSliceLODOnCloud { int lodCount = lodLevels.ordinal(); - int[] localIndex = new int[2]; + int[] localIndex = new int[3]; int[] voxelPos = new int[3]; int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; @@ -153,7 +163,7 @@ public class CreateVDSSliceLODOnCloud { for (int lod = 0 ; lod <= lodCount ; ++lod) { VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( layout, // layout - DimensionsND.DIMENSIONS_01.ordinal(), // dimension ND + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND lod, // lod channel, // channel 200, // max pages @@ -175,7 +185,7 @@ public class CreateVDSSliceLODOnCloud { VolumeDataPage page = pageAccessor.createPage(i); System.out.print("LOD : " + lod + " / Page " + (i + 1) + " / " + chunkCount); - VolumeIndexer2D outputIndexer = new VolumeIndexer2D(page, 0, lod, DimensionsND.DIMENSIONS_01.ordinal(), layout); + VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, lod, DimensionsND.DIMENSIONS_012.ordinal(), layout); float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); int[] numSamplesChunk = new int[3]; @@ -196,15 +206,15 @@ public class CreateVDSSliceLODOnCloud { int chunkSizeZ = chunkMax[0] - chunkMin[0]; // get pitch and allocate buffer size - //page.getPitch(pitch); - //float[] output = new float[page.getAllocatedBufferSize()]; + page.getPitch(pitch); + float[] output = new float[page.getAllocatedBufferSize()]; // or read buffer of page - float[] output = page.readFloatBuffer(pitch); + //float[] output = page.readFloatBuffer(pitch); - DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); - DoubleSummaryStatistics stats = ds.summaryStatistics(); - System.out.print( " Page Buffer Size : " + output.length + " / [" + stats.getMin() + "," + stats.getMax() + "]"); + //DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); + //DoubleSummaryStatistics stats = ds.summaryStatistics(); + System.out.print( " Page Buffer Size : " + output.length);// + " / [" + stats.getMin() + "," + stats.getMax() + "]"); // dimension of buffer System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); @@ -215,13 +225,13 @@ public class CreateVDSSliceLODOnCloud { int[] numSamples = numSamplesChunk; for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) { - voxelPos[2] = iDim2; + localIndex[2] = iDim2; for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) { + localIndex[1] = iDim1; for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { localIndex[0] = iDim0; - localIndex[1] = iDim1; int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); - for (int vp = 0; vp < 2; ++vp) { + for (int vp = 0; vp < 3; ++vp) { voxelPos[vp] = voxelIndex[vp]; } @@ -249,12 +259,22 @@ public class CreateVDSSliceLODOnCloud { timeRead += (time_2 - time_1); timeVolIndex += (time_3 - time_2); timeWrite += (time_4 - time_3); + } pageAccessor.commit(); - pageAccessor.setMaxPages(0); + //pageAccessor.setMaxPages(0); + int errorCount = accessManager.uploadErrorCount(); + System.out.println("There were " + errorCount + " upload error."); + if (errorCount >= 0) { + int currentUploadErrorCode = accessManager.getCurrentUploadErrorCode(); + System.out.println("Upload error : " + currentUploadErrorCode); + } accessManager.flushUploadQueue(); accessManager.destroyVolumeDataPageAccessor(pageAccessor); + + //accessManager.clearUploadErrors(); + //accessManager.forceClearAllUploadErrors(); } displayStatistics(timeRead, timeVolIndex, timeWrite); diff --git a/java/java/demo/CreateVDSSliceMultiLayoutLODOnCloud.java b/java/java/demo/CreateVDSSliceMultiLayoutLODOnCloud.java new file mode 100644 index 00000000..6005da99 --- /dev/null +++ b/java/java/demo/CreateVDSSliceMultiLayoutLODOnCloud.java @@ -0,0 +1,515 @@ +import org.opengroup.openvds.*; + +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; + +public class CreateVDSSliceMultiLayoutLODOnCloud { + + // usage : CreateVDSWithLOD n /path/to/file + // where n is the LOD level wanted + public static void main(String[] args) { + try { + if (!checkParams(args)) { + System.out.println("Bad params, usage : n"); + System.out.println("where n is the LOD level wanted (0 <= lod <= 12)"); + } + else { + Instant start = Instant.now(); + process(Integer.parseInt(args[0])); + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } + } + catch (Throwable t) { + System.out.println(); + t.printStackTrace(); + } + } + + private static boolean checkParams(String[] args) { + if (args == null || args.length != 1) { + return false; + } + try { + Integer lod = Integer.parseInt(args[0]); + if (lod < 0 || lod > 12) { + return false; + } + } + catch (NumberFormatException nfe) { + return false; + } + return true; + } + + static void process(int lodParam) throws Exception { + + int samplesX = 300; // time + int samplesY = 500; // XL + int samplesZ = 500; // IL + VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; + + double sizeX = samplesX; + double sizeY = samplesY; + double sizeZ = samplesZ; + + double distMax = distance3D(0, 0, 0, sizeX, sizeY, sizeZ); + double cycles = Math.PI * 2 * 20; + double midX = samplesX / 2f; + double midY = samplesY / 2f; + double midZ = samplesZ / 2f; + + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_32; + int negativeMargin = 4; + int positiveMargin = 4; + int brickSize2DMultiplier = 20; + + VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.values()[lodParam]; + + //VolumeDataLayoutDescriptor.Options layoutOptions = VolumeDataLayoutDescriptor.Options.NONE; + VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, true,false,0); + + List axisDescriptors = new ArrayList<>(); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "s", 0.0f,4.f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "",1000f, 1000f + samplesY - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); + + List channelDescriptors = new ArrayList<>(); + + float rangeMin = -1f; + float rangeMax = 1f; + float[] scaleOffset = getScaleOffsetForFormat(rangeMin, rangeMax, true, format); + + VolumeDataChannelDescriptor channelDescriptor = new VolumeDataChannelDescriptor(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", + "", + rangeMin, // range min + rangeMax, // range max + VolumeDataMapping.DIRECT, // mapping + 1, // mapped value count + false, // is discrete + true, // is renderable + false, // allow lossy compression + false, // use zip for lossless compresion + true, // use no value + -999.25f, // no value + scaleOffset[0], // integer scale + scaleOffset[1]); // integer offset + channelDescriptors.add(channelDescriptor); + + + //OpenVDS::InMemoryOpenOptions options; + // options Minio +// String pBucket = "miniovaap"; // the bucket of the VDS +// String pKey = "CubeVDS_Test_NoLOD_Layouts.vds"; // the key prefix of the VDS ? +// String pRegion = "eu-west-3"; // the region of the bucket of the VDS +// String pEndpointOverride = "https://webvr.int.com/"; // This parameter allows to override the endpoint url +// AWSOpenOptions optionsAWS = new AWSOpenOptions(pBucket, pKey, pRegion, pEndpointOverride); +// optionsAWS.accessKeyId = ""; // ? +// optionsAWS.secretKey = ""; +// optionsAWS.sessionToken = ""; // ? + + // S3 + String pBucket = "intindexertest"; // the bucket of the VDS + String pKey = "java/CubeVDS_Test_NoLOD_B32_MultiLayout.vds"; // the key prefix of the VDS ? + String pRegion = "us-east-2"; // the region of the bucket of the VDS + String pEndpointOverride = ""; // This parameter allows to override the endpoint url + AWSOpenOptions optionsAWS = new AWSOpenOptions(pBucket, pKey, pRegion, pEndpointOverride); + optionsAWS.accessKeyId = ""; // ? + optionsAWS.secretKey = ""; + optionsAWS.sessionToken = ""; // ? + + MetadataContainer metadataContainer = new MetadataContainer(); + metadataContainer.setMetadataString("Infos", "Creation", "Sliced LOD 500x500x300 Brick 32 (Margin 4) + 2D layout (01,02,12)"); + + //VDSFileOpenOptions optionsFile = new VDSFileOpenOptions("/media/hdd/VDS/cubeMult.vds"); + + VdsHandle vds = OpenVDS.create(optionsAWS, layoutDescriptor, + axisDescriptors.toArray(new VolumeDataAxisDescriptor[0]), + channelDescriptors.toArray(new VolumeDataChannelDescriptor[0]), metadataContainer); + + + VolumeDataLayout layout = vds.getLayout(); + //ASSERT_TRUE(layout); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + + int dimensionality = layout.getDimensionality(); + long times[] = new long[] {0L, 0L, 0L}; + + int lodCount = lodLevels.ordinal(); + + System.out.println("\nCreate 3D Bricks"); + create012Layout(distMax, cycles, midX, midY, midZ, layout, accessManager, channel, times, lodCount); + + System.out.println("\nCreate 01 Layout"); + create2DLayout(distMax, cycles, midX, midY, midZ, layout, accessManager, channel, times, lodCount, DimensionsND.DIMENSIONS_01); + + System.out.println("\nCreate 02 Layout"); + create2DLayout(distMax, cycles, midX, midY, midZ, layout, accessManager, channel, times, lodCount, DimensionsND.DIMENSIONS_02); + + System.out.println("\nCreate 12 Layout"); + create2DLayout(distMax, cycles, midX, midY, midZ, layout, accessManager, channel, times, lodCount, DimensionsND.DIMENSIONS_12); + + displayStatistics(times[0], times[1], times[2]); + + vds.close(); // equivalent to OpenVDS.close(vds); ? + System.out.println("VDS closed"); + } + + private static void create012Layout(double distMax, double cycles, double midX, double midY, double midZ, VolumeDataLayout layout, VolumeDataAccessManager accessManager, + int channel, long[] times, int lodCount) { + + int[] localIndex = new int[3]; + int[] voxelPos = new int[3]; + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + for (int lod = 0 ; lod <= lodCount ; ++lod) { + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + DimensionsND.DIMENSIONS_012.ordinal(), // dimension ND + lod, // lod + channel, // channel + 200, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + + //ASSERT_TRUE(pageAccessor); + int paLOD = pageAccessor.getLOD(); + int paCI = pageAccessor.getChannelIndex(); + int[] paNumSamples = pageAccessor.getNumSamples(); + + int chunkCount = (int) pageAccessor.getChunkCount(); + System.out.println("LOD : " + lod + " Chunk count : " + chunkCount); + + for (int i = 0; i < chunkCount; i++) { + + long time_1 = System.currentTimeMillis(); + + VolumeDataPage page = pageAccessor.createPage(i); + System.out.print("LOD : " + lod + " / Page " + (i + 1) + " / " + chunkCount); + + VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, lod, DimensionsND.DIMENSIONS_012.ordinal(), layout); + float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); + + int[] numSamplesChunk = new int[3]; + int[] numSamplesDB = new int[3]; + + for (int j = 0; j < 3; j++) { + numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); + numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); + } + System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); + System.out.print("\tDimensions DataBlock : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); + + page.getMinMax(chunkMin, chunkMax); + + System.out.print("\tCoords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[2] + "/" + chunkMax[2]); + int chunkSizeY = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + + // get pitch and allocate buffer size + page.getPitch(pitch); + float[] output = new float[page.getAllocatedBufferSize()]; + + // or read buffer of page + //float[] output = page.readFloatBuffer(pitch); + + //DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); + //DoubleSummaryStatistics stats = ds.summaryStatistics(); + System.out.print( " Page Buffer Size : " + output.length);// + " / [" + stats.getMin() + "," + stats.getMax() + "]"); + // dimension of buffer + System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); + + long time_2 = System.currentTimeMillis(); + + int[] numSamples = numSamplesChunk; + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) { + localIndex[2] = iDim2; + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) { + localIndex[1] = iDim1; + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + localIndex[0] = iDim0; + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); + for (int vp = 0; vp < 3; ++vp) { + voxelPos[vp] = voxelIndex[vp]; + } + + float value = 0f; + double dist = 0; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = (float) Math.sin((dist * cycles) / distMax); + + int iPos = outputIndexer.localIndexToDataIndex(localIndex); + output[iPos] = value; + } + } + } + + // write buffer then release page + long time_3 = System.currentTimeMillis(); + page.writeFloatBuffer(output, pitch); + page.pageRelease(); + long time_4 = System.currentTimeMillis(); + + times[0] += (time_2 - time_1); + times[1] += (time_3 - time_2); + times[2] += (time_4 - time_3); + } + + pageAccessor.commit(); + //pageAccessor.setMaxPages(0); + int errorCount = accessManager.uploadErrorCount(); + System.out.println("There were " + errorCount + " upload error."); + if (errorCount >= 0) { + int currentUploadErrorCode = accessManager.getCurrentUploadErrorCode(); + System.out.println("Upload error : " + currentUploadErrorCode); + } + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + + //accessManager.clearUploadErrors(); + //accessManager.forceClearAllUploadErrors(); + } + } + + private static void create2DLayout(double distMax, double cycles, double midX, double midY, double midZ, VolumeDataLayout layout, VolumeDataAccessManager accessManager, + int channel, long[] times, int lodCount, DimensionsND dimLYT) { + + int[] localIndex = new int[3]; + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + for (int lod = 0 ; lod <= lodCount ; ++lod) { + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + dimLYT.ordinal(), // dimension ND + lod, // lod + channel, // channel + 200, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + //ASSERT_TRUE(pageAccessor); + int paLOD = pageAccessor.getLOD(); + int paCI = pageAccessor.getChannelIndex(); + int[] paNumSamples = pageAccessor.getNumSamples(); + + int chunkCount = (int) pageAccessor.getChunkCount(); + System.out.println("LOD : " + lod + " Chunk count : " + chunkCount); + + for (int i = 0; i < chunkCount; i++) { + + long time_1 = System.currentTimeMillis(); + + VolumeDataPage page = pageAccessor.createPage(i); + System.out.print("LOD : " + lod + " / Page " + (i + 1) + " / " + chunkCount); + + VolumeIndexer2D outputIndexer = new VolumeIndexer2D(page, 0, lod, dimLYT.ordinal(), layout); + float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); + + int[] numSamplesChunk = new int[3]; + int[] numSamplesDB = new int[3]; + + for (int j = 0; j < 3 ; j++) { + numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); + numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); + } + System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); + System.out.print("\tDimensions DataBlock : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); + + page.getMinMax(chunkMin, chunkMax); + + // determine fixed position index and value + int fixedCoordIndex = -1; + int fixedCoordValue = -1; + for (int pos = 0; pos < 3 && fixedCoordIndex == -1 ; ++pos) { + if (Math.abs(chunkMax[pos] - chunkMin[pos]) == 1) { + fixedCoordIndex = pos; + fixedCoordValue = chunkMin[pos]; + } + } + + System.out.print("\tCoords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + "/" + chunkMin[2] + "/" + chunkMax[2]); + int chunkSizeY = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + + // get pitch and allocate buffer size + page.getPitch(pitch); + float[] output = new float[page.getAllocatedBufferSize()]; + + // or read buffer of page + //float[] output = page.readFloatBuffer(pitch); + + System.out.print( " Page Buffer Size : " + output.length);// + " / [" + stats.getMin() + "," + stats.getMax() + "]"); + // dimension of buffer + System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + "," + pitch[2] + "]"); + + long time_2 = System.currentTimeMillis(); + + int[] numSamples = numSamplesChunk; + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) { + localIndex[2] = iDim2; + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) { + localIndex[1] = iDim1; + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + localIndex[0] = iDim0; + int[] local2DIndex = convertTo2DLocalIndex(localIndex, fixedCoordIndex); + int[] voxelIndex = outputIndexer.localChunkIndexToLocalIndex(local2DIndex); + int[] voxelPos = convertTo3DCoord(voxelIndex, fixedCoordIndex, fixedCoordValue); + + float value = 0f; + double dist = 0; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = (float) Math.sin((dist * cycles) / distMax); + + int iPos = outputIndexer.localIndexToDataIndex(local2DIndex); + output[iPos] = value; + } + } + } + + // write buffer then release page + long time_3 = System.currentTimeMillis(); + page.writeFloatBuffer(output, pitch); + page.pageRelease(); + long time_4 = System.currentTimeMillis(); + + times[0] += (time_2 - time_1); + times[1] += (time_3 - time_2); + times[2] += (time_4 - time_3); + } + + pageAccessor.commit(); + //pageAccessor.setMaxPages(0); + int errorCount = accessManager.uploadErrorCount(); + System.out.println("There were " + errorCount + " upload error."); + if (errorCount >= 0) { + int currentUploadErrorCode = accessManager.getCurrentUploadErrorCode(); + System.out.println("Upload error : " + currentUploadErrorCode); + } + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + + //accessManager.clearUploadErrors(); + //accessManager.forceClearAllUploadErrors(); + } + } + + /** + * Convert 3D index to 2D index + */ + private static int[] convertTo2DLocalIndex(int[] localIndex, int fixedCoordIndex) { + int[] local2DIndex = new int[2]; + if (fixedCoordIndex == 0) { + local2DIndex[0] = localIndex[1]; + local2DIndex[1] = localIndex[2]; + } + else if (fixedCoordIndex == 1) { + local2DIndex[0] = localIndex[0]; + local2DIndex[1] = localIndex[2]; + } + else if (fixedCoordIndex == 2) { + local2DIndex[0] = localIndex[0]; + local2DIndex[1] = localIndex[1]; + } + return local2DIndex; + } + + /** + * Convert 2D index to 3D index + * @param voxelIndex + * @param fixedCoordIndex + * @param fixedCoordValue + */ + private static int[] convertTo3DCoord(int[] voxelIndex, int fixedCoordIndex, int fixedCoordValue) { + int[] voxelPos = new int[3]; + voxelPos[fixedCoordIndex] = fixedCoordValue; + if (fixedCoordIndex == 0) { + voxelPos[1] = voxelIndex[0]; + voxelPos[2] = voxelIndex[1]; + } + else if (fixedCoordIndex == 1) { + voxelPos[0] = voxelIndex[0]; + voxelPos[2] = voxelIndex[1]; + } + else if (fixedCoordIndex == 2) { + voxelPos[0] = voxelIndex[0]; + voxelPos[1] = voxelIndex[1]; + } + return voxelPos; + } + + private static void displayStatistics(long timeRead, long timeVolIndex, long timeWrite) { + long totalTime = timeRead + timeVolIndex + timeWrite; + float pctRead = (timeRead * 100f) / (float)totalTime; + float pctVolIndex = (timeVolIndex * 100f) / (float)totalTime; + float pctWrite = (timeWrite * 100f) / (float)totalTime; + + System.out.println("Read took " + timeRead + "ms : " + pctRead + "%"); + System.out.println("Write took " + timeWrite + "ms : " + pctWrite + "%"); + System.out.println("Index compute took " + timeVolIndex + "ms : " + pctVolIndex + "%"); + } + + private static double distance2D(double x1, double y1, double x2, double y2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + return Math.sqrt((diffX * diffX) + (diffY * diffY)); + } + + private static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + double diffZ = z2 - z1; + return Math.sqrt((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); + } + + static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { + float res[] = new float[] {1f, 0f}; + float noValueCmp = useNoValue ? 1f : 0f; + switch (format) { + case FORMAT_U8: + res[0] = 1.f / (255.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_U16: + res[0] = 1.f / (65535.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_R32: + case FORMAT_U32: + case FORMAT_R64: + case FORMAT_U64: + case FORMAT_1BIT: + case FORMAT_ANY: + res[0] = 1.0f; + res[1] = 0.0f; + } + return res; + } + +} diff --git a/java/java/demo/CreateVDSWithLODMultipleLayout.java b/java/java/demo/CreateVDSWithLODMultipleLayout.java new file mode 100644 index 00000000..ffc01144 --- /dev/null +++ b/java/java/demo/CreateVDSWithLODMultipleLayout.java @@ -0,0 +1,344 @@ +import org.opengroup.openvds.*; + +import java.io.File; +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; + +public class CreateVDSWithLODMultipleLayout { + + // usage : CreateVDSWithLOD n /path/to/file + // where n is the LOD level wanted + public static void main(String[] args) { + try { + if (!checkParams(args)) { + System.out.println("Bad params, usage : n /path/to/file"); + System.out.println("where n is the LOD level wanted (0 <= lod <= 12), path must be a valid non existing file path"); + } + else { + Instant start = Instant.now(); + process(Integer.parseInt(args[0]), args[1]); + Instant end = Instant.now(); + + Duration elapsed = Duration.between(start, end); + long hrs = elapsed.toHours(); + long min = elapsed.toMinutes() - (hrs * 60); + long s = (elapsed.toMillis() - (elapsed.toMinutes() * 60 * 1000)) / 1000; + System.out.println("Write VDS TIME : " + hrs + " hrs " + min + " min " + s + "s (" + elapsed.toMillis() + " ms)"); + } + } + catch (Throwable t) { + System.out.println(); + t.printStackTrace(); + } + } + + private static boolean checkParams(String[] args) { + if (args == null || args.length != 2) { + return false; + } + try { + Integer lod = Integer.parseInt(args[0]); + if (lod < 0 || lod > 12) { + return false; + } + } + catch (NumberFormatException nfe) { + return false; + } + String path = args[1]; + File file = new File(path); + try { + file.getCanonicalPath(); + } + catch (IOException e) { + System.err.println("VDS File path is invalid !"); + return false; + } + if (!path.endsWith(".vds")) { + System.err.println("VDS File path must have vds extension !"); + return false; + } + if (file.exists()) { + System.err.println("VDS File already exists !"); + return false; + } + return true; + } + + static void process(int lodParam, String vdsFilePath) throws Exception { + + int samplesX = 200; // time + int samplesY = 300; // XL + int samplesZ = 300; // IL + VolumeDataChannelDescriptor.Format format = VolumeDataChannelDescriptor.Format.FORMAT_R32; + + double sizeX = samplesX; + double sizeY = samplesY; + double sizeZ = samplesZ; + + double distMax = distance3D(0, 0, 0, sizeX, sizeY, sizeZ); + double cycles = Math.PI * 2 * 20; + double midX = samplesX / 2f; + double midY = samplesY / 2f; + double midZ = samplesZ / 2f; + + VolumeDataLayoutDescriptor.BrickSize brickSize = VolumeDataLayoutDescriptor.BrickSize.BRICK_SIZE_32; + int negativeMargin = 4; + int positiveMargin = 4; + int brickSize2DMultiplier = 4; + VolumeDataLayoutDescriptor.LODLevels lodLevels = VolumeDataLayoutDescriptor.LODLevels.values()[lodParam]; + + long timeRead = 0L; + long timeWrite = 0L; + long timeVolIndex = 0L; + + DimensionsND[] layouts = new DimensionsND[] {DimensionsND.DIMENSIONS_012, DimensionsND.DIMENSIONS_01}; + + //VolumeDataLayoutDescriptor.Options layoutOptions = VolumeDataLayoutDescriptor.Options.NONE; + VolumeDataLayoutDescriptor layoutDescriptor = new VolumeDataLayoutDescriptor(brickSize, negativeMargin, positiveMargin, + brickSize2DMultiplier, lodLevels, true, false, 0); + + List axisDescriptors = new ArrayList<>(); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesX, "Sample", "s", 0.0f, 6.0f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesY, "Crossline", "", 1000f, 1000f + samplesY - 1f)); + axisDescriptors.add(new VolumeDataAxisDescriptor(samplesZ, "Inline", "", 1500f, 1500f + samplesZ - 1f)); + + List channelDescriptors = new ArrayList<>(); + + float rangeMin = -1f; + float rangeMax = 1f; + float[] scaleOffset = getScaleOffsetForFormat(rangeMin, rangeMax, true, format); + + VolumeDataChannelDescriptor channelDescriptor = new VolumeDataChannelDescriptor(format, VolumeDataChannelDescriptor.Components.COMPONENTS_1, + "Amplitude", + "", + rangeMin, // range min + rangeMax, // range max + VolumeDataMapping.DIRECT, // mapping + 1, // mapped value count + false, // is discrete + true, // is renderable + false, // allow lossy compression + false, // use zip for lossless compresion + true, // use no value + -999.25f, // no value + scaleOffset[0], // integer scale + scaleOffset[1]); // integer offset + channelDescriptors.add(channelDescriptor); + + + //OpenVDS::InMemoryOpenOptions options; + VDSFileOpenOptions optionsFile = new VDSFileOpenOptions(vdsFilePath); + +// String pBucket = "miniovaap"; // the bucket of the VDS +// String pKey = "CubeTestMultipleLayout_Cloud.vds"; // the key prefix of the VDS ? +// String pRegion = "eu-west-3"; // the region of the bucket of the VDS +// String pEndpointOverride = "https://webvr.int.com/"; // This parameter allows to override the endpoint url +// AWSOpenOptions optionsAWS = new AWSOpenOptions(pBucket, pKey, pRegion, pEndpointOverride); +// optionsAWS.accessKeyId = "minioadmin"; // ? +// optionsAWS.secretKey = "minioadmin"; +// optionsAWS.sessionToken = ""; // ? + VdsError error; + + MetadataContainer metadataContainer = new MetadataContainer(); + metadataContainer.setMetadataString("Test", "String", "Test 2 layouts"); + metadataContainer.setMetadataString("Test", "Data Info", "300x300x200 Brick32 + 2D"); + //metadataContainer.SetMetadataBLOB("categoryBLOB", "BLOB", data, 4 ); + + OpenVDS vds = OpenVDS.create(optionsFile, layoutDescriptor, + axisDescriptors.toArray(new VolumeDataAxisDescriptor[0]), + channelDescriptors.toArray(new VolumeDataChannelDescriptor[0]), metadataContainer); + + for (DimensionsND layoutDim : layouts) { + + VolumeDataLayout layout = vds.getLayout(); + //ASSERT_TRUE(layout); + VolumeDataAccessManager accessManager = vds.getAccessManager(); + //ASSERT_TRUE(accessManager); + + int channel = 0; + + int dimensionality = layout.getDimensionality(); + + + int lodCount = lodLevels.ordinal(); + + int[] localIndex = new int[3]; + int[] voxelPos = new int[3]; + + int[] pitch = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMin = new int[VolumeDataLayout.Dimensionality_Max]; + int[] chunkMax = new int[VolumeDataLayout.Dimensionality_Max]; + + + for (int lod = 0; lod <= lodCount; ++lod) { + VolumeDataPageAccessor pageAccessor = accessManager.createVolumeDataPageAccessor( + layout, // layout + layoutDim.ordinal(), // dimension ND + lod, // lod + channel, // channel + 100, // max pages + VolumeDataAccessManager.AccessMode.Create.getCode()); // access mode + + + //ASSERT_TRUE(pageAccessor); + int paLOD = pageAccessor.getLOD(); + int paCI = pageAccessor.getChannelIndex(); + int[] paNumSamples = pageAccessor.getNumSamples(); + + int chunkCount = (int) pageAccessor.getChunkCount(); + System.out.println("LOD : " + lod + " Chunk count : " + chunkCount); + + for (int i = 0; i < chunkCount; i++) { + + long time_1 = System.currentTimeMillis(); + + VolumeDataPage page = pageAccessor.createPage(i); + System.out.print("LOD : " + lod + " / Page " + (i + 1) + " / " + chunkCount); + + VolumeIndexer3D outputIndexer = new VolumeIndexer3D(page, 0, lod, layoutDim.ordinal(), layout); + float valueRangeScale = outputIndexer.getValueRangeMax() - outputIndexer.getValueRangeMin(); + + int[] numSamplesChunk = new int[3]; + int[] numSamplesDB = new int[3]; + + for (int j = 0; j < 3; j++) { + numSamplesChunk[j] = outputIndexer.getLocalChunkNumSamples(j); + numSamplesDB[j] = outputIndexer.getDataBlockNumSamples(j); + } + System.out.print("\tDimensions Chunk : [" + numSamplesChunk[0] + ", " + numSamplesChunk[1] + ", " + numSamplesChunk[2] + "]"); + System.out.print("\tDimensions DataBlock : [" + numSamplesDB[0] + ", " + numSamplesDB[1] + ", " + numSamplesDB[2] + "]"); + + page.getMinMax(chunkMin, chunkMax); + + System.out.print("\tCoords page : " + chunkMin[0] + "/" + chunkMax[0] + " " + chunkMin[1] + "/" + chunkMax[1] + " " + chunkMin[2] + "/" + chunkMax[2]); + int chunkSizeY = chunkMax[2] - chunkMin[2]; + int chunkSizeX = chunkMax[1] - chunkMin[1]; + int chunkSizeZ = chunkMax[0] - chunkMin[0]; + + // get pitch and allocate buffer size + page.getPitch(pitch); + float[] output = new float[page.getAllocatedBufferSize()]; + + // or read buffer of page + //float[] output = page.readFloatBuffer(pitch); + + //DoubleStream ds = IntStream.range(0, output.length).mapToDouble(oi -> output[oi]); + //DoubleSummaryStatistics stats = ds.summaryStatistics(); + System.out.print(" Page Buffer Size : " + output.length + " ");/// [" + stats.getMin() + "," + stats.getMax() + "]"); + // dimension of buffer + System.out.println(" Pitch : [" + pitch[0] + ", " + pitch[1] + ", " + pitch[2] + "]"); + + int dimPitch = pitch[dimensionality - 1] * (chunkMax[dimensionality - 1] - chunkMin[dimensionality - 1]); + + long time_2 = System.currentTimeMillis(); + + int[] numSamples = numSamplesChunk; + + for (int iDim2 = 0; iDim2 < numSamples[2]; iDim2++) { + localIndex[2] = iDim2; + for (int iDim1 = 0; iDim1 < numSamples[1]; iDim1++) { + localIndex[1] = iDim1; + for (int iDim0 = 0; iDim0 < numSamples[0]; iDim0++) { + localIndex[0] = iDim0; + + int[] voxelIndex = outputIndexer.localIndexToVoxelIndex(localIndex); + for (int vp = 0; vp < 3; ++vp) { + voxelPos[vp] = voxelIndex[vp]; + } + + float value = 0f; + double dist = 0; + if (voxelPos[0] >= midX) { + dist = distance2D(midY, midZ, voxelPos[1], voxelPos[2]); + } else { + dist = distance3D(midX, midY, midZ, voxelPos[0], voxelPos[1], voxelPos[2]); + } + value = (float) Math.sin((dist * cycles) / distMax); + + int iPos = outputIndexer.localIndexToDataIndex(localIndex); + output[iPos] = value; + } + } + } + + // write buffer then release page + long time_3 = System.currentTimeMillis(); + page.writeFloatBuffer(output, pitch); + page.pageRelease(); + long time_4 = System.currentTimeMillis(); + + timeRead += (time_2 - time_1); + timeVolIndex += (time_3 - time_2); + timeWrite += (time_4 - time_3); + } + + pageAccessor.commit(); + pageAccessor.setMaxPages(0); + accessManager.flushUploadQueue(); + accessManager.destroyVolumeDataPageAccessor(pageAccessor); + // TODO check if errors : must call or not some methods? + // accessManager.clearUploadErrors(); + // accessManager.forceClearAllUploadErrors(); + } + } + vds.close(); // equivalent to OpenVDS.close(vds); ? + + displayStatistics(timeRead, timeVolIndex, timeWrite); + + + System.out.println("VDS closed"); + } + + private static void displayStatistics(long timeRead, long timeVolIndex, long timeWrite) { + long totalTime = timeRead + timeVolIndex + timeWrite; + float pctRead = (timeRead * 100f) / (float)totalTime; + float pctVolIndex = (timeVolIndex * 100f) / (float)totalTime; + float pctWrite = (timeWrite * 100f) / (float)totalTime; + + System.out.println("Read took " + timeRead + "ms : " + pctRead + "%"); + System.out.println("Write took " + timeWrite + "ms : " + pctWrite + "%"); + System.out.println("Index compute took " + timeVolIndex + "ms : " + pctVolIndex + "%"); + } + + private static double distance2D(double x1, double y1, double x2, double y2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + return Math.sqrt((diffX * diffX) + (diffY * diffY)); + } + + private static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2) { + double diffX = x2 - x1; + double diffY = y2 - y1; + double diffZ = z2 - z1; + return Math.sqrt((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); + } + + static float[] getScaleOffsetForFormat(float min, float max, boolean useNoValue, VolumeDataChannelDescriptor.Format format) { + float res[] = new float[] {1f, 0f}; + float noValueCmp = useNoValue ? 1f : 0f; + switch (format) { + case FORMAT_U8: + res[0] = 1.f / (255.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_U16: + res[0] = 1.f / (65535.f - noValueCmp) * (max - min); + res[1] = min; + break; + case FORMAT_R32: + case FORMAT_U32: + case FORMAT_R64: + case FORMAT_U64: + case FORMAT_1BIT: + case FORMAT_ANY: + res[0] = 1.0f; + res[1] = 0.0f; + } + return res; + } + +} -- GitLab From 3cb8ce28468e8976903710204c8dbcba735e0e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 13 Nov 2020 09:22:32 +0100 Subject: [PATCH 024/194] Seismic DMS --- 3rdparty/.gitignore | 1 + 3rdparty/BuildDms/CMakeLists.txt | 123 ++++++++++ CMake/Build3rdParty.cmake | 4 +- CMake/BuildDms.cmake | 6 + CMake/CopyDllForTarget.cmake | 2 +- CMake/Fetch3rdPartyInBuild.cmake | 1 + CMakeLists.txt | 4 +- python/openvds/PyGlobal.cpp | 14 ++ python/openvds/generated_docstrings.h | 18 ++ src/OpenVDS/CMakeLists.txt | 10 +- src/OpenVDS/IO/IOManager.cpp | 10 +- src/OpenVDS/IO/IOManager.h | 10 +- src/OpenVDS/IO/IOManagerDms.cpp | 288 ++++++++++++++++++++++++ src/OpenVDS/IO/IOManagerDms.h | 105 +++++++++ src/OpenVDS/OpenVDS.cpp | 41 +++- src/OpenVDS/OpenVDS/OpenVDS.h | 20 ++ tests/OpenVDS/GlobalStateTest.cpp | 2 +- tests/OpenVDS/MultiThreadedRequests.cpp | 2 +- tests/OpenVDS/RequestCancellation.cpp | 2 +- tests/OpenVDS/WaitForCompletion.cpp | 2 +- tests/io/IoErrorHandling.cpp | 2 +- tests/io/IoManagerBasic.cpp | 2 +- tests/io/IoPerformance.cpp | 2 +- tools/SEGYImport/SEGYImport.cpp | 2 +- 24 files changed, 652 insertions(+), 21 deletions(-) create mode 100644 3rdparty/BuildDms/CMakeLists.txt create mode 100644 CMake/BuildDms.cmake create mode 100644 src/OpenVDS/IO/IOManagerDms.cpp create mode 100644 src/OpenVDS/IO/IOManagerDms.h diff --git a/3rdparty/.gitignore b/3rdparty/.gitignore index 918fb330..0fab897d 100644 --- a/3rdparty/.gitignore +++ b/3rdparty/.gitignore @@ -15,3 +15,4 @@ google-cloud-cpp* java* google_nlohmann* libressl* +dms* diff --git a/3rdparty/BuildDms/CMakeLists.txt b/3rdparty/BuildDms/CMakeLists.txt new file mode 100644 index 00000000..3ff90267 --- /dev/null +++ b/3rdparty/BuildDms/CMakeLists.txt @@ -0,0 +1,123 @@ +if(WIN32) + list(APPEND CMAKE_MODULE_PATH ${dmsCMakeDir}/modules/version_info_win32) +endif() + +set (CMAKE_CXX_STANDARD 14) +set (CMAKE_CXX_STANDARD_REQUIRED ON) + +include_directories(${dmsCMakeDir}/src/core) +include_directories(${dmsCMakeDir}/src/lib) +include_directories(${dmsCMakeDir}/src/lib/cloud/providers) + +if (NOT DISABLE_AZURE_IOMANAGER) + set(BUILD_POLYCLOUD ON) + add_definitions(-DPOLYCLOUD) +endif() +# retrieve sources +file(GLOB SRC_CORE ${dmsCMakeDir}/src/core/*.cc) +file(GLOB SRC_LIB_ACCESSORS ${dmsCMakeDir}/src/lib/accessors/*.cc) +file(GLOB SRC_LIB_PROVIDERS ${dmsCMakeDir}/src/lib/cloud/providers/*.cc) +if(BUILD_POLYCLOUD) + file(GLOB SRC_LIB_PROVIDERS_AZURE ${dmsCMakeDir}/src/lib/cloud/providers/azure/*.cc) +endif() +file(GLOB SRC_LIB_HTTP ${dmsCMakeDir}/src/lib/http/*.cc) +file(GLOB SRC_LIB_JSON ${dmsCMakeDir}/src/lib/json/*.cpp) +file(GLOB SRC_LIB_AUTH ${dmsCMakeDir}/src/lib/auth/*.cc) +file(GLOB SRC_LIB_SHARED ${dmsCMakeDir}/src/lib/shared/*.cc) +set(SOURCES ${SRC_CORE} ${SRC_LIB_ACCESSORS} ${SRC_LIB_PROVIDERS} ${SRC_LIB_HTTP} ${SRC_LIB_JSON} ${SRC_LIB_AUTH} ${SRC_LIB_SHARED}) +if(BUILD_POLYCLOUD) + set(SOURCES ${SOURCES} ${SRC_LIB_PROVIDERS_AZURE}) +endif() + +# set major library versions +if(NOT DEFINED LIB_VERSION_MAJOR) + set(LIB_VERSION_MAJOR 0) +endif() + +# set minor library versions +if(NOT DEFINED LIB_VERSION_MINOR) + set(LIB_VERSION_MINOR 0) +endif() + +# set patch library versions +if(NOT DEFINED LIB_VERSION_PATCH) + if(DEFINED LIBVERSION) # backward compatibility (old naming convention for patch) + set(LIB_VERSION_PATCH ${LIBVERSION}) + elseif(DEFINED SDAPI_WIN_VERSION) # backward compatibility (old naming convention for patch) + set(LIB_VERSION_PATCH ${SDAPI_WIN_VERSION}) + else() + set(LIB_VERSION_PATCH 0) + endif() +endif() + +# set the versioninfo file for win32 +if(WIN32) + include(generate_product_version) + generate_product_version( + VersionFilesOutputVariable + NAME "sdapi" + VERSION_MAJOR ${LIB_VERSION_MAJOR} + VERSION_MINOR ${LIB_VERSION_MINOR} + VERSION_PATCH ${LIB_VERSION_PATCH} + COMPANY_NAME "Schlumberger" + ) +endif() + + +add_library (sdapi_objects OBJECT ${SOURCES} ${VersionFilesOutputVariable}) + +get_property(link_3rdparty_release GLOBAL PROPERTY OPENVDS_LINK_LIBRARIES_RELEASE) +get_property(link_3rdparty_debug GLOBAL PROPERTY OPENVDS_LINK_LIBRARIES_DEBUG) +get_property(runtime_3rdparty_release GLOBAL PROPERTY OPENVDS_RUNTIME_LIBS_RELEASE) +get_property(runtime_3rdparty_debug GLOBAL PROPERTY OPENVDS_RUNTIME_LIBS_DEBUG) +get_property(include_3rdparty GLOBAL PROPERTY OPENVDS_INCLUDE_LIBRARIES) +get_property(dependency_targets_3rdparty GLOBAL PROPERTY OPENVDS_DEPENDENCY_TARGETS) + +foreach(DEP ${dependency_targets_3rdparty}) + add_dependencies(sdapi_objects ${DEP}) +endforeach() + + +addSystemHeadersToTarget(sdapi_objects "${include_3rdparty}") +target_link_libraries(sdapi_objects PUBLIC $<$>:${link_3rdparty_release}> $<$:${link_3rdparty_debug}>) + +if (UNIX) + find_package(Boost REQUIRED COMPONENTS system date_time regex) + target_link_libraries(sdapi_objects PUBLIC Boost::system) +endif() + +add_library(sdapi SHARED $) +target_link_libraries(sdapi PUBLIC sdapi_objects) + +if (WIN32) + if(DEFINED LIB_VERSION_ON_NAME) + set_target_properties(sdapi PROPERTIES + OUTPUT_NAME "sdapi_${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}" + POSITION_INDEPENDENT_CODE ON) + else() + set_target_properties(sdapi PROPERTIES + OUTPUT_NAME "sdapi" + POSITION_INDEPENDENT_CODE ON) + endif() +else() + set_target_properties(sdapi PROPERTIES + SOVERSION ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR} + VERSION ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH} + CXX_VISIBILITY_PRESET hidden + OUTPUT_NAME "sdapi" + POSITION_INDEPENDENT_CODE ON) + +endif() + +install(TARGETS sdapi sdapi_objects + EXPORT sdapi-export + ARCHIVE + DESTINATION ${CMAKE_INSTALL_LIBDIR}${LIB_TOOLSET_DIR} + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR}${LIB_TOOLSET_DIR} + RUNTIME + DESTINATION ${CMAKE_INSTALL_BINDIR}${LIB_TOOLSET_DIR} + FRAMEWORK + DESTINATION framework +) + diff --git a/CMake/Build3rdParty.cmake b/CMake/Build3rdParty.cmake index 381766d2..89d36984 100644 --- a/CMake/Build3rdParty.cmake +++ b/CMake/Build3rdParty.cmake @@ -9,7 +9,7 @@ include(CMake/BuildLibUV.cmake) include(CMake/BuildLibreSSL.cmake) include(CMake/BuildCrc32c.cmake) include(CMake/BuildGoogleClient.cmake) - +include(CMake/BuildDms.cmake) if (BUILD_ZLIB) include(CMake/BuildZlib.cmake) endif() @@ -39,5 +39,5 @@ macro(build3rdparty) BuildLibreSSL() BuildCrc32c() endif() - #BuildGoogleClient() + BuildDms() endmacro() diff --git a/CMake/BuildDms.cmake b/CMake/BuildDms.cmake new file mode 100644 index 00000000..f6374591 --- /dev/null +++ b/CMake/BuildDms.cmake @@ -0,0 +1,6 @@ +macro(BuildDms) + message("DMS SOURCE DIR ${dms_SOURCE_DIR}") + set(dmsCMakeDir "${dms_SOURCE_DIR}/src") + #BuildExternal(dms "${dms_VERSION}" "" "CMake/BuildDms" "" "" "" "" "-DdmsCMakeDir=${dmsCMakeDir}") + add_subdirectory(3rdparty/BuildDms) +endmacro() diff --git a/CMake/CopyDllForTarget.cmake b/CMake/CopyDllForTarget.cmake index e95e8d4b..b6b97dfd 100644 --- a/CMake/CopyDllForTarget.cmake +++ b/CMake/CopyDllForTarget.cmake @@ -21,7 +21,7 @@ function(copyDllForTarget target) file(GLOB runtime_debug "${debug_location}/*.dll") else() add_custom_command(OUTPUT "${target}_copy_vds" - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ $ $ DEPENDS openvds) set_property(SOURCE "${target}_copy_vds" PROPERTY SYMBOLIC ON diff --git a/CMake/Fetch3rdPartyInBuild.cmake b/CMake/Fetch3rdPartyInBuild.cmake index dc68d060..33ec2044 100644 --- a/CMake/Fetch3rdPartyInBuild.cmake +++ b/CMake/Fetch3rdPartyInBuild.cmake @@ -82,6 +82,7 @@ function(Fetch3rdParty) Fetch3rdParty_Package(absl 20200225.2 https://codeload.github.com/abseil/abseil-cpp/tar.gz/20200225.2 SHA256=f41868f7a938605c92936230081175d1eae87f6ea2c248f41077c8f88316f111) Fetch3rdParty_Package(crc32c 1.1.1 https://codeload.github.com/google/crc32c/tar.gz/1.1.1 SHA256=a6533f45b1670b5d59b38a514d82b09c6fb70cc1050467220216335e873074e8) Fetch3rdParty_Package(google-cloud-cpp 1.14.0 https://codeload.github.com/googleapis/google-cloud-cpp/tar.gz/v1.14.0 SHA256=839b2d4dcb36a671734dac6b30ea8c298bbeaafcf7a45ee4a7d7aa5986b16569) + Fetch3rdParty_Package(dms c7ba5398 https://community.opengroup.org/osdu/platform/domain-data-mgmt-services/seismic/seismic-dms-suite/seismic-store-cpp-lib/-/archive/c7ba5398eca0f131fbd9bf107e3148d5fd1c512c/seismic-store-cpp-lib-master.tar.gz SHA256=c1ab5348e255246e8e8d23f07dba9f6c3cbcd0b5beb5e48a7138ebbefdf79d8d) Fetch3rdParty_File(testng java 6.14.3 jar https://repo1.maven.org/maven2/org/testng/testng/6.14.3/testng-6.14.3.jar MD5=9f17a8f9e99165e148c42b21f4b63d7c) Fetch3rdParty_File(jcommander java 1.72 jar https://repo1.maven.org/maven2/com/beust/jcommander/1.72/jcommander-1.72.jar MD5=9fde6bc0ba1032eceb7267fd1ad1657b) Fetch3rdParty_FileTarget(google_nlohmann google/cloud/storage/internal nlohmann_json.hpp 3.4.0 https://raw.githubusercontent.com/nlohmann/json/v3.4.0/single_include/nlohmann/json.hpp MD5=27f3760c1d3a0fff7d8a2407d8db8f9d) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a76ae93..362089be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,8 @@ if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")) endif() include(CMake/SetWarnings.cmake) +include(CMake/AddSystemHeadersToTarget.cmake) +include(CMake/CopyDllForTarget.cmake) include(CMake/Fetch3rdPartyInBuild.cmake) Fetch3rdParty() @@ -154,8 +156,6 @@ Fetch3rdParty() include(CMake/Build3rdParty.cmake) build3rdparty() -include(CMake/CopyDllForTarget.cmake) -include(CMake/AddSystemHeadersToTarget.cmake) #this is disabled in Java and Python since they match dl open with a string set(CMAKE_DEBUG_POSTFIX d) diff --git a/python/openvds/PyGlobal.cpp b/python/openvds/PyGlobal.cpp index 3bbfadbf..68d9d3f5 100644 --- a/python/openvds/PyGlobal.cpp +++ b/python/openvds/PyGlobal.cpp @@ -43,6 +43,7 @@ PyGlobal::initModule(py::module& m) OpenOptions_ConnectionType_.value("Azure" , OpenOptions::ConnectionType::Azure , OPENVDS_DOCSTRING(OpenOptions_ConnectionType_Azure)); OpenOptions_ConnectionType_.value("AzurePresigned" , OpenOptions::ConnectionType::AzurePresigned, OPENVDS_DOCSTRING(OpenOptions_ConnectionType_AzurePresigned)); OpenOptions_ConnectionType_.value("GoogleStorage" , OpenOptions::ConnectionType::GoogleStorage, OPENVDS_DOCSTRING(OpenOptions_ConnectionType_GoogleStorage)); + OpenOptions_ConnectionType_.value("DMS" , OpenOptions::ConnectionType::DMS , OPENVDS_DOCSTRING(OpenOptions_ConnectionType_DMS)); OpenOptions_ConnectionType_.value("Http" , OpenOptions::ConnectionType::Http , OPENVDS_DOCSTRING(OpenOptions_ConnectionType_Http)); OpenOptions_ConnectionType_.value("VDSFile" , OpenOptions::ConnectionType::VDSFile , OPENVDS_DOCSTRING(OpenOptions_ConnectionType_VDSFile)); OpenOptions_ConnectionType_.value("InMemory" , OpenOptions::ConnectionType::InMemory , OPENVDS_DOCSTRING(OpenOptions_ConnectionType_InMemory)); @@ -170,6 +171,18 @@ PyGlobal::initModule(py::module& m) GoogleOpenOptions_CredentialsType_.value("SignedUrlPath" , GoogleOpenOptions::CredentialsType::SignedUrlPath, OPENVDS_DOCSTRING(GoogleOpenOptions_CredentialsType_SignedUrlPath)); GoogleOpenOptions_CredentialsType_.value("SignedUrlJson" , GoogleOpenOptions::CredentialsType::SignedUrlJson, OPENVDS_DOCSTRING(GoogleOpenOptions_CredentialsType_SignedUrlJson)); + // DMSOpenOptions + py::class_> + DMSOpenOptions_(m,"DMSOpenOptions", OPENVDS_DOCSTRING(DMSOpenOptions)); + + DMSOpenOptions_.def(py::init< >(), OPENVDS_DOCSTRING(DMSOpenOptions_DMSOpenOptions)); + DMSOpenOptions_.def(py::init(), py::arg("sdAuthorityUrl").none(false), py::arg("sdApiKey").none(false), py::arg("sdToken").none(false), py::arg("datasetPath").none(false), py::arg("logLevel").none(false), OPENVDS_DOCSTRING(DMSOpenOptions_DMSOpenOptions_2)); + DMSOpenOptions_.def_readwrite("sdAuthorityUrl" , &DMSOpenOptions::sdAuthorityUrl, OPENVDS_DOCSTRING(DMSOpenOptions_sdAuthorityUrl)); + DMSOpenOptions_.def_readwrite("sdApiKey" , &DMSOpenOptions::sdApiKey , OPENVDS_DOCSTRING(DMSOpenOptions_sdApiKey)); + DMSOpenOptions_.def_readwrite("sdToken" , &DMSOpenOptions::sdToken , OPENVDS_DOCSTRING(DMSOpenOptions_sdToken)); + DMSOpenOptions_.def_readwrite("datasetPath" , &DMSOpenOptions::datasetPath , OPENVDS_DOCSTRING(DMSOpenOptions_datasetPath)); + DMSOpenOptions_.def_readwrite("logLevel" , &DMSOpenOptions::logLevel , OPENVDS_DOCSTRING(DMSOpenOptions_logLevel)); + // HttpOpenOptions py::class_> HttpOpenOptions_(m,"HttpOpenOptions", OPENVDS_DOCSTRING(HttpOpenOptions)); @@ -237,6 +250,7 @@ PyGlobal::initModule(py::module& m) case OpenOptions::ConnectionType::AzurePresigned : conn = std::string("AzurePresigned" ); break; case OpenOptions::ConnectionType::GoogleStorage : conn = std::string("GoogleStorage" ); break; case OpenOptions::ConnectionType::Http : conn = std::string("Http" ); break; + case OpenOptions::ConnectionType::DMS : conn = std::string("Dms" ); break; case OpenOptions::ConnectionType::VDSFile : conn = std::string("VDSFile" ); break; case OpenOptions::ConnectionType::InMemory : conn = std::string("InMemory" ); break; case OpenOptions::ConnectionType::Other : conn = std::string("Other" ); break; diff --git a/python/openvds/generated_docstrings.h b/python/openvds/generated_docstrings.h index b62c2e0a..cd654fb6 100644 --- a/python/openvds/generated_docstrings.h +++ b/python/openvds/generated_docstrings.h @@ -389,6 +389,22 @@ static const char *__doc_OpenVDS_CreateVolumeDataAccessor_20 = R"doc()doc"; static const char *__doc_OpenVDS_CreateVolumeDataAccessor_21 = R"doc()doc"; +static const char *__doc_OpenVDS_DMSOpenOptions = R"doc()doc"; + +static const char *__doc_OpenVDS_DMSOpenOptions_DMSOpenOptions = R"doc()doc"; + +static const char *__doc_OpenVDS_DMSOpenOptions_DMSOpenOptions_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_DMSOpenOptions_datasetPath = R"doc()doc"; + +static const char *__doc_OpenVDS_DMSOpenOptions_logLevel = R"doc()doc"; + +static const char *__doc_OpenVDS_DMSOpenOptions_sdApiKey = R"doc()doc"; + +static const char *__doc_OpenVDS_DMSOpenOptions_sdAuthorityUrl = R"doc()doc"; + +static const char *__doc_OpenVDS_DMSOpenOptions_sdToken = R"doc()doc"; + static const char *__doc_OpenVDS_DimensionsND = R"doc(2D or 3D dimension group\n)doc"; static const char *__doc_OpenVDS_DimensionsND_Dimensions_01 = R"doc()doc"; @@ -1486,6 +1502,8 @@ static const char *__doc_OpenVDS_OpenOptions_ConnectionType_AzurePresigned = R"d static const char *__doc_OpenVDS_OpenOptions_ConnectionType_ConnectionTypeCount = R"doc()doc"; +static const char *__doc_OpenVDS_OpenOptions_ConnectionType_DMS = R"doc()doc"; + static const char *__doc_OpenVDS_OpenOptions_ConnectionType_GoogleStorage = R"doc()doc"; static const char *__doc_OpenVDS_OpenOptions_ConnectionType_Http = R"doc()doc"; diff --git a/src/OpenVDS/CMakeLists.txt b/src/OpenVDS/CMakeLists.txt index 36a8b51d..1cfca7e1 100644 --- a/src/OpenVDS/CMakeLists.txt +++ b/src/OpenVDS/CMakeLists.txt @@ -130,7 +130,7 @@ set_source_files_properties(VDS/FSE/fse_decompress.cpp PROPERTIES COMPILE_FLAGS add_library(openvds_objects OBJECT ${PRIVATE_HEADER_FILES} ${EXPORTED_HEADER_FILES} - ${SOURCE_FILES}) + ${SOURCE_FILES} "IO/IOManagerDms.cpp") setWarningFlagsForTarget(openvds_objects) @@ -232,6 +232,14 @@ else() addGoogleCloudToTarget(openvds_objects) endif() +if (DISABLE_DMS_IOMANAGER) + target_compile_definitions(openvds_objects PRIVATE OPENVDS_NO_DMS_IOMANAGER) + set_source_files_properties(IO/IOManagerDms.cpp PROPERTIES HEADER_FILE_ONLY TRUE) +else() + target_include_directories(openvds_objects PRIVATE ${dms_SOURCE_DIR}/src/src/core ${dms_SOURCE_DIR}/src/src/lib) + target_link_libraries(openvds_objects PRIVATE $) +endif() + if (WIN32) target_link_libraries(openvds_objects PUBLIC crypt32 wsock32 ws2_32) else() diff --git a/src/OpenVDS/IO/IOManager.cpp b/src/OpenVDS/IO/IOManager.cpp index 52bf3535..69ed51c9 100644 --- a/src/OpenVDS/IO/IOManager.cpp +++ b/src/OpenVDS/IO/IOManager.cpp @@ -37,6 +37,8 @@ #include "IOManagerHttp.h" #endif +#include "IOManagerDms.h" + namespace OpenVDS { Request::Request(const std::string& objectName) @@ -52,7 +54,7 @@ IOManager::IOManager(OpenOptions::ConnectionType connectionType) } IOManager::~IOManager() {} -IOManager* IOManager::CreateIOManager(const OpenOptions& options, Error &error) +IOManager* IOManager::CreateIOManager(const OpenOptions& options, IOManager::AccessPattern accessPattern, Error &error) { switch(options.connectionType) { @@ -76,6 +78,8 @@ IOManager* IOManager::CreateIOManager(const OpenOptions& options, Error &error) case OpenOptions::Http: return new IOManagerHttp(static_cast(options), error); #endif + case OpenOptions::DMS: + return new IOManagerDms(static_cast(options), accessPattern, error); case OpenOptions::InMemory: return IOManagerInMemory::CreateIOManagerInMemory(static_cast(options), error); default: @@ -85,12 +89,12 @@ IOManager* IOManager::CreateIOManager(const OpenOptions& options, Error &error) } } -IOManager *IOManager::CreateIOManager(const StringWrapper &url, const StringWrapper &connectionString, Error& error) +IOManager *IOManager::CreateIOManager(const StringWrapper &url, const StringWrapper &connectionString, IOManager::AccessPattern accessPattern, Error& error) { std::unique_ptr openOptions(CreateOpenOptions(url, connectionString, error)); if (error.code || !openOptions) return nullptr; - return CreateIOManager(*(openOptions.get()), error); + return CreateIOManager(*(openOptions.get()), accessPattern, error); } } diff --git a/src/OpenVDS/IO/IOManager.h b/src/OpenVDS/IO/IOManager.h index 19979035..5b3d924e 100644 --- a/src/OpenVDS/IO/IOManager.h +++ b/src/OpenVDS/IO/IOManager.h @@ -61,6 +61,12 @@ namespace OpenVDS class IOManager { public: + enum AccessPattern + { + ReadOnly, + ReadWrite + }; + IOManager(OpenOptions::ConnectionType connectionType); virtual ~IOManager(); virtual std::shared_ptr ReadObjectInfo(const std::string &objectName, std::shared_ptr handler) = 0; @@ -78,10 +84,10 @@ namespace OpenVDS OpenOptions::ConnectionType connectionType() const { return m_connectionType; } OPENVDS_EXPORT - static IOManager *CreateIOManager(const OpenOptions &options, Error &error); + static IOManager *CreateIOManager(const OpenOptions &options, IOManager::AccessPattern accessPattern, Error &error); OPENVDS_EXPORT - static IOManager *CreateIOManager(const StringWrapper& url, const StringWrapper& connectionString, Error& error); + static IOManager *CreateIOManager(const StringWrapper& url, const StringWrapper& connectionString, IOManager::AccessPattern accessPattern, Error& error); protected: OpenOptions::ConnectionType m_connectionType; diff --git a/src/OpenVDS/IO/IOManagerDms.cpp b/src/OpenVDS/IO/IOManagerDms.cpp new file mode 100644 index 00000000..a55f2f22 --- /dev/null +++ b/src/OpenVDS/IO/IOManagerDms.cpp @@ -0,0 +1,288 @@ +#include "IOManagerDms.h" + +#include +#include + +#include + +#ifdef _MSC_VER +#pragma warning( disable : 4275 ) +#endif +#include + +namespace OpenVDS +{ + GetHeadRequestDms::GetHeadRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, const std::shared_ptr& handler) + : Request(id) + , m_dataset(dataset) + , m_handler(handler) + , m_cancelled(false) + , m_done(false) + { + } + + GetHeadRequestDms::~GetHeadRequestDms() + { + GetHeadRequestDms::Cancel(); + } + + void GetHeadRequestDms::WaitForFinish() + { + m_job.get(); + std::unique_lock lock(m_mutex); + m_waitForFinish.wait(lock, [this] + { + return m_done; + }); + + } + + bool GetHeadRequestDms::IsDone() const + { + std::unique_lock lock(m_mutex); + return m_done; + } + + bool GetHeadRequestDms::IsSuccess(Error& error) const + { + std::unique_lock lock(m_mutex); + if (!m_done) + { + error.code = -1; + error.string = "GetHead not done."; + return false; + } + error = m_error; + return m_error.code == 0; + } + + void GetHeadRequestDms::Cancel() + { + m_cancelled = true; + } + + ReadObjectInfoRequestDms::ReadObjectInfoRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, const std::shared_ptr& handler) + : GetHeadRequestDms(dataset, id, handler) + { + } + + struct Notifier + { + Notifier(std::condition_variable& conditional_variable) + : conditional_variable(conditional_variable) + { + } + ~Notifier() + { + conditional_variable.notify_all(); + } + std::condition_variable& conditional_variable; + }; + void ReadObjectInfoRequestDms::run(const std::string& requestName, std::weak_ptr request, ThreadPool &threadPool) + { + m_job = threadPool.Enqueue([requestName, request]() { + (void)requestName; //silence warning + auto request_ptr = request.lock(); + if (!request_ptr) + return; + std::unique_lock lock(request_ptr->m_mutex); + + Notifier notifier(request_ptr->m_waitForFinish); + + if (request_ptr->m_cancelled) + return; + + //no headers are exposed + + request_ptr->m_done; + request_ptr->m_handler->Completed(*request_ptr, request_ptr->m_error); + }); + } + + DownloadRequestDms::DownloadRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, const std::shared_ptr& handler) + : GetHeadRequestDms(dataset, id, handler) + { + } + + void DownloadRequestDms::run(const std::string& requestName, const IORange& range, std::weak_ptr request, ThreadPool &threadPool) + { + m_job = threadPool.Enqueue([requestName, request]() { + auto request_ptr = request.lock(); + if (!request_ptr) + return; + std::unique_lock lock(request_ptr->m_mutex); + Notifier notifier(request_ptr->m_waitForFinish); + if (request_ptr->m_cancelled) + return; + + try + { + auto size = request_ptr->m_dataset.getBlockSize(requestName); + request_ptr->m_data.resize(size); + + if (size) + { + request_ptr->m_dataset.readBlock(requestName, (char*)request_ptr->m_data.data(), 0, request_ptr->m_data.size()); + } + } + catch (const seismicdrive::SDException& ex) + { + request_ptr->m_error.code = -1; + request_ptr->m_error.string = ex.what(); + } + catch (...) + { + request_ptr->m_error.code = -1; + request_ptr->m_error.string = "Unknown exception in DMS upload"; + } + request_ptr->m_handler->HandleData(std::move(request_ptr->m_data)); + + request_ptr->m_done = true; + request_ptr->m_handler->Completed(*request_ptr, request_ptr->m_error); + }); + } + + UploadRequestDms::UploadRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, std::function completedCallback) + : Request(id) + , m_dataset(dataset) + , m_completedCallback(completedCallback) + , m_cancelled(false) + , m_done(false) + { + } + + void UploadRequestDms::run(const std::string& requestName, const std::string& contentDispositionFilename, const std::string& contentType, const std::vector>& metadataHeader, std::shared_ptr> data, std::weak_ptr request, ThreadPool &threadPool) + { + m_job = threadPool.Enqueue([requestName, contentDispositionFilename, contentType, metadataHeader, data, request]() { + auto request_ptr = request.lock(); + if (!request_ptr) + return; + + std::unique_lock lock(request_ptr->m_mutex); + + Notifier notifier(request_ptr->m_waitForFinish); + + if (request_ptr->m_cancelled) + return; + + try + { + request_ptr->m_dataset.writeBlock(requestName, (const char*)data->data(), data->size(), false); + } + catch (const seismicdrive::SDException& ex) + { + request_ptr->m_error.code = -1; + request_ptr->m_error.string = ex.what(); + } + catch (...) + { + request_ptr->m_error.code = -1; + request_ptr->m_error.string = "Unknown exception in DMS upload"; + } + + request_ptr->m_done = true; + if (request_ptr->m_completedCallback) + request_ptr->m_completedCallback(*request_ptr, request_ptr->m_error); + }); + } + + void UploadRequestDms::WaitForFinish() + { + m_job.get(); + std::unique_lock lock(m_mutex); + + m_waitForFinish.wait(lock, [this] + { + return this->m_done; + }); + } + + bool UploadRequestDms::IsDone() const + { + std::unique_lock lock(m_mutex); + return m_done; + } + + bool UploadRequestDms::IsSuccess(Error& error) const + { + std::unique_lock lock(m_mutex); + if (!m_done) + { + error.code = -1; + error.string = "Upload not done."; + return false; + } + error = m_error; + return m_error.code == 0; + } + + void UploadRequestDms::Cancel() + { + m_cancelled = true; + } + + IOManagerDms::IOManagerDms(const DMSOpenOptions& openOptions, IOManager::AccessPattern accessPatttern, Error& error) + : IOManager(openOptions.connectionType) + , m_opened(false) + , m_threadPool(1) + { + try { + m_sdManager.reset(new seismicdrive::SDManager(openOptions.sdAuthorityUrl, openOptions.sdApiKey, openOptions.logLevel)); + m_sdManager->setAuthProviderFromString(openOptions.sdToken); + m_dataset.reset(new seismicdrive::SDGenericDataset(m_sdManager.get(), openOptions.datasetPath, openOptions.logLevel)); + + seismicdrive::SDDatasetDisposition disposition = seismicdrive::SDDatasetDisposition::READ_ONLY; + switch (accessPatttern) + { + case IOManager::ReadOnly: + disposition = seismicdrive::SDDatasetDisposition::READ_ONLY; + break; + case IOManager::ReadWrite: + disposition = seismicdrive::SDDatasetDisposition::OVERWRITE; + break; + } + m_dataset->open(disposition); + m_opened = true; + } + catch (seismicdrive::SDException &exception) + { + error.string = exception.what(); + error.code = -1; + } + catch (...) + { + error.string = "Unknwon DMS exception."; + error.code = -1; + } + } + + IOManagerDms::~IOManagerDms() + { + if (m_dataset && m_opened) + { + m_dataset->close(); + } + } + + std::shared_ptr IOManagerDms::ReadObjectInfo(const std::string& objectName, std::shared_ptr handler) + { + auto req = std::make_shared(*m_dataset, objectName, handler); + req->run(objectName, req, m_threadPool); + return req; + } + + std::shared_ptr IOManagerDms::ReadObject(const std::string& requestName, std::shared_ptr handler, const IORange& range) + { + auto req = std::make_shared(*m_dataset, requestName, handler); + req->run(requestName, range, req, m_threadPool); + return req; + } + + std::shared_ptr IOManagerDms::WriteObject(const std::string& requestName, const std::string& contentDispostionFilename, const std::string& contentType, const std::vector>& metadataHeader, std::shared_ptr> data, std::function completedCallback) + { + auto req = std::make_shared(*m_dataset, requestName, completedCallback); + req->run(requestName, contentDispostionFilename, contentType, metadataHeader, data, req, m_threadPool); + return req; + } + +} diff --git a/src/OpenVDS/IO/IOManagerDms.h b/src/OpenVDS/IO/IOManagerDms.h new file mode 100644 index 00000000..8c53986f --- /dev/null +++ b/src/OpenVDS/IO/IOManagerDms.h @@ -0,0 +1,105 @@ +#ifndef IOMANAGERDMS_H +#define IOMANAGERDMS_H + +#include "IOManager.h" + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4251) +#endif +#include +#include +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#include +#include +#include +#include + +#include "ThreadPool.h" + +namespace OpenVDS +{ + class GetHeadRequestDms : public Request + { + public: + GetHeadRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, const std::shared_ptr& handler); + ~GetHeadRequestDms() override; + + void WaitForFinish() override; + bool IsDone() const override; + bool IsSuccess(Error& error) const override; + void Cancel() override; + + seismicdrive::SDGenericDataset & m_dataset; + std::shared_ptr m_handler; + std::atomic_bool m_cancelled; + bool m_done; + Error m_error; + std::condition_variable m_waitForFinish; + mutable std::mutex m_mutex; + std::future m_job; + }; + + class ReadObjectInfoRequestDms : public GetHeadRequestDms + { + public: + ReadObjectInfoRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, const std::shared_ptr& handler); + + void run(const std::string& requestName, std::weak_ptr request, ThreadPool &threadPool); + + }; + + class DownloadRequestDms : public GetHeadRequestDms + { + public: + DownloadRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, const std::shared_ptr& handler); + + void run(const std::string& requestName, const IORange& range, std::weak_ptr request, ThreadPool &threadPool); + + IORange m_requestedRange; + std::vector m_data; + }; + + class UploadRequestDms : public Request + { + public: + UploadRequestDms(seismicdrive::SDGenericDataset &dataset, const std::string& id, std::function completedCallback); + void run(const std::string& requestName, const std::string& contentDispositionFilename, const std::string& contentType, const std::vector>& metadataHeader, std::shared_ptr> data, std::weak_ptr uploadRequest, ThreadPool &threadPool); + void WaitForFinish() override; + bool IsDone() const override; + bool IsSuccess(Error& error) const override; + void Cancel() override; + + seismicdrive::SDGenericDataset & m_dataset; + std::function m_completedCallback; + std::shared_ptr> m_data; + std::atomic_bool m_cancelled; + bool m_done; + Error m_error; + std::condition_variable m_waitForFinish; + mutable std::mutex m_mutex; + std::future m_job; + }; + + class IOManagerDms : public IOManager + { + public: + IOManagerDms(const DMSOpenOptions& openOptions, IOManager::AccessPattern accessPatttern, Error& error); + ~IOManagerDms() override; + + std::shared_ptr ReadObjectInfo(const std::string& objectName, std::shared_ptr handler) override; + std::shared_ptr ReadObject(const std::string& requestName, std::shared_ptr handler, const IORange& range = IORange()) override; + std::shared_ptr WriteObject(const std::string& requestName, const std::string& contentDispostionFilename, const std::string& contentType, const std::vector>& metadataHeader, std::shared_ptr> data, std::function completedCallback = nullptr) override; + + private: + std::unique_ptr m_sdManager; + std::unique_ptr m_dataset; + bool m_opened; + ThreadPool m_threadPool; + }; +} + +#endif //IOMANAGERDMS_H diff --git a/src/OpenVDS/OpenVDS.cpp b/src/OpenVDS/OpenVDS.cpp index cb3f2250..ca11e267 100644 --- a/src/OpenVDS/OpenVDS.cpp +++ b/src/OpenVDS/OpenVDS.cpp @@ -337,6 +337,39 @@ static std::unique_ptr createGoogleOpenOptions(const StringWrapper& return openOptions; } +static std::unique_ptr createDMSOpenOptions(const StringWrapper& url, const StringWrapper& connectionString, Error& error) +{ + std::unique_ptr openOptions(new DMSOpenOptions()); + openOptions->logLevel = 0; + auto connectionStringMap = ParseConnectionString(connectionString.data, connectionString.size, error); + if (error.code) + { + return nullptr; + } + + if (url.size < 1) + { + error.code = -1; + error.string = "SD url is missing bucket"; + } + + openOptions->datasetPath = std::string(url.data, url.data + url.size); + + for (auto& connectionPair : connectionStringMap) + { + if (connectionPair.first == "sdauthorityurl") + openOptions->sdAuthorityUrl = connectionPair.second; + if (connectionPair.first == "sdapikey") + openOptions->sdApiKey = connectionPair.second; + if (connectionPair.first == "sdtoken") + openOptions->sdToken = connectionPair.second; + if (connectionPair.first == "loglevel") + openOptions->logLevel = atoi(connectionPair.second.c_str()); + } + + return openOptions; +} + static std::unique_ptr createHttpOpenOptions(const StringWrapper& url, const StringWrapper& connectionString, Error& error) { std::unique_ptr openOptions(new HttpOpenOptions(std::string(url.data, url.data + url.size))); @@ -378,6 +411,10 @@ OpenOptions* CreateOpenOptions(StringWrapper url, StringWrapper connectionString { openOptions = createGoogleOpenOptions(removeProtocol(url, "gs://"), connectionString, error); } + else if (isProtocol(url, "sd://")) + { + openOptions = createDMSOpenOptions(url, connectionString, error); + } else if (isProtocol(url, "http://") || isProtocol(url, "https://")) { openOptions = createHttpOpenOptions(url, connectionString, error); @@ -458,7 +495,7 @@ VDS *Open(const OpenOptions &options, Error &error) if(options.connectionType != OpenOptions::VDSFile) { - std::unique_ptr ioManager(IOManager::CreateIOManager(options, error)); + std::unique_ptr ioManager(IOManager::CreateIOManager(options, IOManager::AccessPattern::ReadOnly, error)); if (error.code) return nullptr; @@ -672,7 +709,7 @@ VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& l if(options.connectionType != OpenOptions::VDSFile) { - std::unique_ptr ioManager(IOManager::CreateIOManager(options, error)); + std::unique_ptr ioManager(IOManager::CreateIOManager(options, IOManager::AccessPattern::ReadWrite, error)); if (error.code) return nullptr; diff --git a/src/OpenVDS/OpenVDS/OpenVDS.h b/src/OpenVDS/OpenVDS/OpenVDS.h index 175cc84b..4f1b68a8 100644 --- a/src/OpenVDS/OpenVDS/OpenVDS.h +++ b/src/OpenVDS/OpenVDS/OpenVDS.h @@ -45,6 +45,7 @@ struct OpenOptions Azure, AzurePresigned, GoogleStorage, + DMS, Http, VDSFile, InMemory, @@ -436,6 +437,25 @@ struct GoogleOpenOptions : OpenOptions } }; +struct DMSOpenOptions : OpenOptions +{ + DMSOpenOptions() : OpenOptions(DMS) {} + + DMSOpenOptions(std::string const& sdAuthorityUrl, std::string const& sdApiKey, std::string const &sdToken, std::string const &datasetPath, int logLevel) + : OpenOptions(DMS) + , sdAuthorityUrl(sdAuthorityUrl) + , sdApiKey(sdApiKey) + , sdToken(sdToken) + , logLevel(logLevel) + {} + + std::string sdAuthorityUrl; + std::string sdApiKey; + std::string sdToken; + std::string datasetPath; + int logLevel; +}; + /// /// Options for opening a VDS with a plain http url. /// If there are query parameters in then they will be appended to the different sub urls. diff --git a/tests/OpenVDS/GlobalStateTest.cpp b/tests/OpenVDS/GlobalStateTest.cpp index 3d6f0e00..769ab1f0 100644 --- a/tests/OpenVDS/GlobalStateTest.cpp +++ b/tests/OpenVDS/GlobalStateTest.cpp @@ -51,7 +51,7 @@ TEST(GlobalState, basic) OpenVDS::InMemoryOpenOptions options; OpenVDS::Error error; - std::unique_ptr inMemory(OpenVDS::IOManagerInMemory::CreateIOManager(options, error)); + std::unique_ptr inMemory(OpenVDS::IOManagerInMemory::CreateIOManager(options, OpenVDS::IOManager::AccessPattern::ReadWrite, error)); { IOManagerFacadeLight *iomanager = new IOManagerFacadeLight(inMemory.get()); diff --git a/tests/OpenVDS/MultiThreadedRequests.cpp b/tests/OpenVDS/MultiThreadedRequests.cpp index a8b7d2f7..ccda4490 100644 --- a/tests/OpenVDS/MultiThreadedRequests.cpp +++ b/tests/OpenVDS/MultiThreadedRequests.cpp @@ -40,7 +40,7 @@ TEST(Multithreading, requests) OpenVDS::InMemoryOpenOptions options; OpenVDS::Error error; - std::unique_ptr inMemory(OpenVDS::IOManagerInMemory::CreateIOManager(options, error)); + std::unique_ptr inMemory(OpenVDS::IOManagerInMemory::CreateIOManager(options, OpenVDS::IOManager::AccessPattern::ReadWrite, error)); { IOManagerFacadeLight *iomanager = new IOManagerFacadeLight(inMemory.get()); diff --git a/tests/OpenVDS/RequestCancellation.cpp b/tests/OpenVDS/RequestCancellation.cpp index 7958269e..eb58cca4 100644 --- a/tests/OpenVDS/RequestCancellation.cpp +++ b/tests/OpenVDS/RequestCancellation.cpp @@ -33,7 +33,7 @@ TEST(OpenVDS_integration, RequestCancellation) { OpenVDS::InMemoryOpenOptions options; OpenVDS::Error error; - std::unique_ptr inMemory(OpenVDS::IOManagerInMemory::CreateIOManager(options, error)); + std::unique_ptr inMemory(OpenVDS::IOManagerInMemory::CreateIOManager(options, OpenVDS::IOManager::AccessPattern::ReadWrite, error)); SlowIOManager* slowIOManager = new SlowIOManager(50, inMemory.get()); std::unique_ptr handle(generateSimpleInMemory3DVDS(60,60,60, OpenVDS::VolumeDataChannelDescriptor::Format_R32, OpenVDS::VolumeDataLayoutDescriptor::BrickSize_32, slowIOManager), OpenVDS::Close); fill3DVDSWithBitNoise(handle.get()); diff --git a/tests/OpenVDS/WaitForCompletion.cpp b/tests/OpenVDS/WaitForCompletion.cpp index 47d3a510..1d683c38 100644 --- a/tests/OpenVDS/WaitForCompletion.cpp +++ b/tests/OpenVDS/WaitForCompletion.cpp @@ -33,7 +33,7 @@ TEST(WaitForCompletion, waitTimeout) { OpenVDS::InMemoryOpenOptions options; OpenVDS::Error error; - std::unique_ptr inMemory(OpenVDS::IOManagerInMemory::CreateIOManager(options, error)); + std::unique_ptr inMemory(OpenVDS::IOManagerInMemory::CreateIOManager(options, OpenVDS::IOManager::AccessPattern::ReadWrite, error)); SlowIOManager* slowIOManager = new SlowIOManager(50, inMemory.get()); std::unique_ptr handle(generateSimpleInMemory3DVDS(60,60,60, OpenVDS::VolumeDataChannelDescriptor::Format_R32, OpenVDS::VolumeDataLayoutDescriptor::BrickSize_32, slowIOManager), OpenVDS::Close); fill3DVDSWithBitNoise(handle.get()); diff --git a/tests/io/IoErrorHandling.cpp b/tests/io/IoErrorHandling.cpp index 749cef25..2f237656 100644 --- a/tests/io/IoErrorHandling.cpp +++ b/tests/io/IoErrorHandling.cpp @@ -35,7 +35,7 @@ struct IOErrorHandlingFixture : public ::testing::Test static void SetUpTestSuite() { OpenVDS::Error error; OpenVDS::InMemoryOpenOptions options; - inMemoryIOManager = OpenVDS::IOManagerInMemory::CreateIOManager(options, error); + inMemoryIOManager = OpenVDS::IOManagerInMemory::CreateIOManager(options, OpenVDS::IOManager::AccessPattern::ReadWrite, error); IOManagerFacade* facadeIoManager = new IOManagerFacade(inMemoryIOManager); diff --git a/tests/io/IoManagerBasic.cpp b/tests/io/IoManagerBasic.cpp index 7c093749..a17753ac 100644 --- a/tests/io/IoManagerBasic.cpp +++ b/tests/io/IoManagerBasic.cpp @@ -72,7 +72,7 @@ TEST(IOTests, basicIOTest) OpenVDS::Error ioManagerError; - OpenVDS::IOManager * m_ioManager = reinterpret_cast (OpenVDS::IOManager::CreateIOManager(url, connectionString, ioManagerError)); + OpenVDS::IOManager * m_ioManager = reinterpret_cast (OpenVDS::IOManager::CreateIOManager(url, connectionString, OpenVDS::IOManager::AccessPattern::ReadWrite, ioManagerError)); const char hash[] = "Test text"; std::vector base64Hash; diff --git a/tests/io/IoPerformance.cpp b/tests/io/IoPerformance.cpp index 235440cf..5a624eb8 100644 --- a/tests/io/IoPerformance.cpp +++ b/tests/io/IoPerformance.cpp @@ -67,7 +67,7 @@ TEST(IOTests, performance) GTEST_SKIP() << "This test has to be enabled manually"; OpenVDS::Error error; - OpenVDS::IOManager* ioManager = OpenVDS::IOManager::CreateIOManager(url, connectionString, error); + OpenVDS::IOManager* ioManager = OpenVDS::IOManager::CreateIOManager(url, connectionString, OpenVDS::IOManager::AccessPattern::ReadWrite, error); int mega = 1 << 20; int chunkSize = mega * 4; diff --git a/tools/SEGYImport/SEGYImport.cpp b/tools/SEGYImport/SEGYImport.cpp index ccd752cc..1930bc86 100644 --- a/tools/SEGYImport/SEGYImport.cpp +++ b/tools/SEGYImport/SEGYImport.cpp @@ -82,7 +82,7 @@ static DataProvider CreateDataProviderFromFile(const std::string &filename, Open static DataProvider CreateDataProviderFromOpenOptions(const std::string &url, const std::string &connectionString, const std::string &objectId, OpenVDS::Error &error) { - std::unique_ptr ioManager(OpenVDS::IOManager::CreateIOManager(url, connectionString, error)); + std::unique_ptr ioManager(OpenVDS::IOManager::CreateIOManager(url, connectionString, OpenVDS::IOManager::AccessPattern::ReadOnly, error)); if (error.code) return DataProvider((OpenVDS::IOManager *)nullptr, "", error); return DataProvider(ioManager.release(), objectId, error); -- GitLab From b879e5c2e664359e5a23260c77564760f6c76c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 5 Feb 2021 09:34:00 +0100 Subject: [PATCH 025/194] fix azure io manager. Specifying a zero value range does not work anymore --- src/OpenVDS/IO/IOManagerAzure.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/OpenVDS/IO/IOManagerAzure.cpp b/src/OpenVDS/IO/IOManagerAzure.cpp index 3b2c3a34..119c5081 100644 --- a/src/OpenVDS/IO/IOManagerAzure.cpp +++ b/src/OpenVDS/IO/IOManagerAzure.cpp @@ -198,7 +198,14 @@ void DownloadRequestAzure::run(azure::storage::cloud_blob_container& container, m_requestedRange = range; m_blob = container.get_block_blob_reference(convertToUtilString(requestName)); - m_task = m_blob.download_range_to_stream_async(m_outStream.create_ostream(), range.start, range.end - range.start, azure::storage::access_condition(), local_options, m_context, m_cancelTokenSrc.get_token()); + if (range.end - range.start) + { + m_task = m_blob.download_range_to_stream_async(m_outStream.create_ostream(), range.start, range.end - range.start, azure::storage::access_condition(), local_options, m_context, m_cancelTokenSrc.get_token()); + } + else + { + m_task = m_blob.download_to_stream_async(m_outStream.create_ostream(), azure::storage::access_condition(), local_options, m_context, m_cancelTokenSrc.get_token()); + } m_task.then([request, this](pplx::task downloadTask) { auto downloadRequest = request.lock(); -- GitLab From 0db692cc332d0ae01ea031c3cc951b6cbb67292a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 8 Feb 2021 17:05:10 +0100 Subject: [PATCH 026/194] Make DMS code use multiple threads --- src/OpenVDS/IO/IOManagerDms.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/OpenVDS/IO/IOManagerDms.cpp b/src/OpenVDS/IO/IOManagerDms.cpp index a55f2f22..2cb94804 100644 --- a/src/OpenVDS/IO/IOManagerDms.cpp +++ b/src/OpenVDS/IO/IOManagerDms.cpp @@ -115,6 +115,7 @@ namespace OpenVDS if (request_ptr->m_cancelled) return; + lock.unlock(); try { auto size = request_ptr->m_dataset.getBlockSize(requestName); @@ -124,14 +125,17 @@ namespace OpenVDS { request_ptr->m_dataset.readBlock(requestName, (char*)request_ptr->m_data.data(), 0, request_ptr->m_data.size()); } + lock.lock(); } catch (const seismicdrive::SDException& ex) { + lock.lock(); request_ptr->m_error.code = -1; request_ptr->m_error.string = ex.what(); } catch (...) { + lock.lock(); request_ptr->m_error.code = -1; request_ptr->m_error.string = "Unknown exception in DMS upload"; } @@ -165,17 +169,21 @@ namespace OpenVDS if (request_ptr->m_cancelled) return; + lock.unlock(); try { request_ptr->m_dataset.writeBlock(requestName, (const char*)data->data(), data->size(), false); + lock.lock(); } catch (const seismicdrive::SDException& ex) { + lock.lock(); request_ptr->m_error.code = -1; request_ptr->m_error.string = ex.what(); } catch (...) { + lock.lock(); request_ptr->m_error.code = -1; request_ptr->m_error.string = "Unknown exception in DMS upload"; } @@ -224,7 +232,7 @@ namespace OpenVDS IOManagerDms::IOManagerDms(const DMSOpenOptions& openOptions, IOManager::AccessPattern accessPatttern, Error& error) : IOManager(openOptions.connectionType) , m_opened(false) - , m_threadPool(1) + , m_threadPool(16) { try { m_sdManager.reset(new seismicdrive::SDManager(openOptions.sdAuthorityUrl, openOptions.sdApiKey, openOptions.logLevel)); -- GitLab From fda27aa40ff2cbab5f06b39ca4f6bcebcfc2fb93 Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Tue, 9 Feb 2021 08:56:28 +0000 Subject: [PATCH 027/194] Binary distribution fixes --- CMakeLists.txt | 2 ++ examples/CMakeLists.txt | 2 +- src/OpenVDS/CMakeLists.txt | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 362089be..7280a110 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,6 +144,8 @@ endif() if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")) add_compile_options(-Werror=return-type) + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") endif() include(CMake/SetWarnings.cmake) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d854c7ee..faa428c0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,7 +6,7 @@ if (CMAKE_PROJECT_NAME STREQUAL "OpenVDSExamples") project(getting-started) set(openvds_DIR "${INSTALLED_LIB_RELATIVE_TO_EXAMPLES}/cmake/openvds") find_package(openvds REQUIRED) - find_package(threads REQUIRED) + find_package(Threads REQUIRED) find_package(OpenMP) endif() add_subdirectory(SliceDump) diff --git a/src/OpenVDS/CMakeLists.txt b/src/OpenVDS/CMakeLists.txt index 1cfca7e1..429194d6 100644 --- a/src/OpenVDS/CMakeLists.txt +++ b/src/OpenVDS/CMakeLists.txt @@ -236,6 +236,7 @@ if (DISABLE_DMS_IOMANAGER) target_compile_definitions(openvds_objects PRIVATE OPENVDS_NO_DMS_IOMANAGER) set_source_files_properties(IO/IOManagerDms.cpp PROPERTIES HEADER_FILE_ONLY TRUE) else() + add_dependencies(openvds_objects sdapi) target_include_directories(openvds_objects PRIVATE ${dms_SOURCE_DIR}/src/src/core ${dms_SOURCE_DIR}/src/src/lib) target_link_libraries(openvds_objects PRIVATE $) endif() @@ -297,8 +298,6 @@ foreach(item ${link_3rdparty_release}) target_link_libraries(openvds PRIVATE optimized ${item}) endforeach() - - if (ENABLE_RUNPATH_ORIGIN) set_target_properties(openvds PROPERTIES -- GitLab From e52f6f47609b93ac13155bcd6251e4ec17ab8f37 Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Tue, 9 Feb 2021 11:36:37 +0000 Subject: [PATCH 028/194] Make packages private --- 3rdparty/BuildDms/CMakeLists.txt | 2 +- examples/SliceDump/CMakeLists.txt | 5 ++++- python/openvds/CMakeLists.txt | 5 +++++ src/OpenVDS/CMakeLists.txt | 23 +++++++++++------------ tests/CMakeLists.txt | 3 +++ 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/3rdparty/BuildDms/CMakeLists.txt b/3rdparty/BuildDms/CMakeLists.txt index 3ff90267..1eb48e58 100644 --- a/3rdparty/BuildDms/CMakeLists.txt +++ b/3rdparty/BuildDms/CMakeLists.txt @@ -83,7 +83,7 @@ target_link_libraries(sdapi_objects PUBLIC $<$>:${link_3rdpa if (UNIX) find_package(Boost REQUIRED COMPONENTS system date_time regex) - target_link_libraries(sdapi_objects PUBLIC Boost::system) + target_link_libraries(sdapi_objects PRIVATE Boost::system) endif() add_library(sdapi SHARED $) diff --git a/examples/SliceDump/CMakeLists.txt b/examples/SliceDump/CMakeLists.txt index 80a618bb..38cb9068 100644 --- a/examples/SliceDump/CMakeLists.txt +++ b/examples/SliceDump/CMakeLists.txt @@ -1,5 +1,8 @@ add_executable(slicedump main.cpp) -target_link_libraries(slicedump openvds::openvds) +target_link_libraries(slicedump PRIVATE openvds::openvds) +if (OpenMP_CXX_FOUND) + target_link_libraries(slicedump PRIVATE OpenMP::OpenMP_CXX) +endif() set_target_properties(slicedump PROPERTIES FOLDER examples) setWarningFlagsForTarget(slicedump) diff --git a/python/openvds/CMakeLists.txt b/python/openvds/CMakeLists.txt index 28e801fd..71b4fa9f 100644 --- a/python/openvds/CMakeLists.txt +++ b/python/openvds/CMakeLists.txt @@ -62,6 +62,11 @@ copyDllForTarget(core) setWarningFlagsForTarget(core) target_link_libraries(core PRIVATE openvds) + +if (OpenMP_CXX_FOUND) + target_link_libraries(core PRIVATE OpenMP::OpenMP_CXX) +endif() + set_target_properties(core PROPERTIES INSTALL_RPATH "\\$\{ORIGIN\}/../../lib${LIBSUFFIX}") install(TARGETS core LIBRARY DESTINATION python/openvds) diff --git a/src/OpenVDS/CMakeLists.txt b/src/OpenVDS/CMakeLists.txt index 429194d6..ca3e47b9 100644 --- a/src/OpenVDS/CMakeLists.txt +++ b/src/OpenVDS/CMakeLists.txt @@ -185,7 +185,7 @@ if (DISABLE_AWS_IOMANAGER) set_source_files_properties(IO/IOManagerAWS.cpp PROPERTIES HEADER_FILE_ONLY TRUE) else() if (aws-cpp-sdk_EXTERNAL_LIBS) - target_link_libraries(openvds_objects PUBLIC ${aws-cpp-sdk_EXTERNAL_LIBS}) + target_link_libraries(openvds_objects PRIVATE ${aws-cpp-sdk_EXTERNAL_LIBS}) endif() endif() @@ -196,7 +196,7 @@ else() #Azure storage exposes boost_system on linux et al. if (UNIX) find_package(Boost REQUIRED COMPONENTS system date_time regex) - target_link_libraries(openvds_objects PUBLIC Boost::system) + target_link_libraries(openvds_objects PRIVATE Boost::system) endif() endif() @@ -207,12 +207,11 @@ if (DISABLE_CURL_IOMANAGER) else() if (NOT BUILD_CURL) find_package(CURL REQUIRED) - target_link_libraries(openvds_objects PUBLIC ${CURL_LIBRARIES}) - target_include_directories(openvds_objects PUBLIC ${CURL_INCLUDE_DIRS}) + target_link_libraries(openvds_objects PRIVATE CURL::libcurl) endif() if (NOT BUILD_UV) find_package(LibUV REQUIRED) - target_link_libraries(openvds_objects PUBLIC LibUV::LibUV) + target_link_libraries(openvds_objects PRIVATE LibUV::LibUV) endif() endif() @@ -227,7 +226,7 @@ if (DISABLE_GCP_IOMANAGER) else() if (WIN32 AND NOT USE_LIBRESSL) find_package(OpenSSL REQUIRED) - target_link_libraries(openvds_objects PUBLIC OpenSSL::SSL OpenSSL::Crypto) + target_link_libraries(openvds_objects PRIVATE OpenSSL::SSL OpenSSL::Crypto) endif() addGoogleCloudToTarget(openvds_objects) endif() @@ -242,22 +241,22 @@ else() endif() if (WIN32) - target_link_libraries(openvds_objects PUBLIC crypt32 wsock32 ws2_32) + target_link_libraries(openvds_objects PRIVATE crypt32 wsock32 ws2_32) else() - target_link_libraries(openvds_objects PUBLIC ssl crypto) + target_link_libraries(openvds_objects PRIVATE ssl crypto) endif() -target_link_libraries(openvds_objects PUBLIC Threads::Threads) +target_link_libraries(openvds_objects PRIVATE Threads::Threads) if (OpenMP_CXX_FOUND) - target_link_libraries(openvds_objects PUBLIC OpenMP::OpenMP_CXX) + target_link_libraries(openvds_objects PRIVATE OpenMP::OpenMP_CXX) endif() if (BUILD_ZLIB) add_dependencies(openvds_objects zlib) else() find_package(ZLIB REQUIRED) - target_link_libraries(openvds_objects PUBLIC ZLIB::ZLIB) + target_link_libraries(openvds_objects PRIVATE ZLIB::ZLIB) endif() if (WIN32) @@ -283,7 +282,7 @@ endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) add_library(openvds $) add_library(openvds::openvds ALIAS openvds) -target_link_libraries(openvds PUBLIC openvds_objects) +target_link_libraries(openvds PRIVATE openvds_objects) set_target_properties(openvds PROPERTIES FRAMEWORK ON diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 103b6a09..c6d377d8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -48,6 +48,9 @@ function(add_test_executable name) target_link_libraries(${name} PRIVATE optimized ${item}) endforeach() + if (OpenMP_CXX_FOUND) + target_link_libraries(${name} PRIVATE OpenMP::OpenMP_CXX) + endif() endfunction() add_test_executable(io_tests -- GitLab From a86433ced5c86687d76dbcab16e2939626b5d2ef Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Tue, 9 Feb 2021 15:30:23 +0000 Subject: [PATCH 029/194] Fix rpath usage in cmake --- CMake/BuildDms.cmake | 1 - CMake/BuildExternal.cmake | 1 - CMakeLists.txt | 2 +- examples/CMakeLists.txt | 1 + python/openvds/CMakeLists.txt | 2 +- src/OpenVDS/CMakeLists.txt | 2 +- src/SEGYUtils/CMakeLists.txt | 2 +- 7 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CMake/BuildDms.cmake b/CMake/BuildDms.cmake index f6374591..e8761d45 100644 --- a/CMake/BuildDms.cmake +++ b/CMake/BuildDms.cmake @@ -1,5 +1,4 @@ macro(BuildDms) - message("DMS SOURCE DIR ${dms_SOURCE_DIR}") set(dmsCMakeDir "${dms_SOURCE_DIR}/src") #BuildExternal(dms "${dms_VERSION}" "" "CMake/BuildDms" "" "" "" "" "-DdmsCMakeDir=${dmsCMakeDir}") add_subdirectory(3rdparty/BuildDms) diff --git a/CMake/BuildExternal.cmake b/CMake/BuildExternal.cmake index cdb11413..4133c856 100644 --- a/CMake/BuildExternal.cmake +++ b/CMake/BuildExternal.cmake @@ -46,7 +46,6 @@ function(BuildExternal name version depends source_dir install_libs_release runt set_property(GLOBAL APPEND PROPERTY OPENVDS_LINK_LIBRARIES_RELEASE "${ABS_PATH_INSTALL_INT_CONFIG}/${LIB}") endforeach() foreach (LIB IN LISTS install_libs_debug) - message("${ABS_PATH_INSTALL_INT_CONFIG}/${LIB}") set_property(GLOBAL APPEND PROPERTY OPENVDS_LINK_LIBRARIES_DEBUG "${ABS_PATH_INSTALL_INT_CONFIG}/${LIB}") endforeach() diff --git a/CMakeLists.txt b/CMakeLists.txt index 7280a110..90508935 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12.0) +cmake_minimum_required(VERSION 3.16.0) find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index faa428c0..1947cb0d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.16.0) project(OpenVDSExamples) if (CMAKE_PROJECT_NAME STREQUAL "OpenVDSExamples") include(modules/InstalledPaths.cmake) diff --git a/python/openvds/CMakeLists.txt b/python/openvds/CMakeLists.txt index 71b4fa9f..869369f0 100644 --- a/python/openvds/CMakeLists.txt +++ b/python/openvds/CMakeLists.txt @@ -67,7 +67,7 @@ if (OpenMP_CXX_FOUND) target_link_libraries(core PRIVATE OpenMP::OpenMP_CXX) endif() -set_target_properties(core PROPERTIES INSTALL_RPATH "\\$\{ORIGIN\}/../../lib${LIBSUFFIX}") +set_target_properties(core PROPERTIES INSTALL_RPATH "$ORIGIN/../../lib${LIBSUFFIX}") install(TARGETS core LIBRARY DESTINATION python/openvds) install(FILES ${pythonsources} DESTINATION python/openvds) diff --git a/src/OpenVDS/CMakeLists.txt b/src/OpenVDS/CMakeLists.txt index ca3e47b9..224b858a 100644 --- a/src/OpenVDS/CMakeLists.txt +++ b/src/OpenVDS/CMakeLists.txt @@ -300,7 +300,7 @@ endforeach() if (ENABLE_RUNPATH_ORIGIN) set_target_properties(openvds PROPERTIES - INSTALL_RPATH "\\$\{ORIGIN\}" + INSTALL_RPATH "$ORIGIN" ) endif() diff --git a/src/SEGYUtils/CMakeLists.txt b/src/SEGYUtils/CMakeLists.txt index 5cc8c9e5..4ba45b5e 100644 --- a/src/SEGYUtils/CMakeLists.txt +++ b/src/SEGYUtils/CMakeLists.txt @@ -25,7 +25,7 @@ target_link_libraries(segyutils PUBLIC openvds) if (ENABLE_RUNPATH_ORIGIN) set_target_properties(segyutils PROPERTIES - INSTALL_RPATH "\\$\{ORIGIN\}" + INSTALL_RPATH "$ORIGIN" ) endif() -- GitLab From a6a49b39bce1a73ed71b252806830e894bbe24b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 11 Feb 2021 09:50:31 +0100 Subject: [PATCH 030/194] Add SOVERSION to the libraries --- CMake/SetCommonTargetProperties.cmake | 12 ++++++++++++ CMake/SetVersionForTarget.cmake | 7 +++++++ CMakeLists.txt | 3 +++ src/OpenVDS/CMakeLists.txt | 16 ++++++---------- src/SEGYUtils/CMakeLists.txt | 22 ++++++---------------- 5 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 CMake/SetCommonTargetProperties.cmake create mode 100644 CMake/SetVersionForTarget.cmake diff --git a/CMake/SetCommonTargetProperties.cmake b/CMake/SetCommonTargetProperties.cmake new file mode 100644 index 00000000..b9f9d754 --- /dev/null +++ b/CMake/SetCommonTargetProperties.cmake @@ -0,0 +1,12 @@ +function(setCommonTargetProperties target) + setWarningFlagsForTarget(${target}) + setVersionForTarget(${target}) +endfunction() + +function(setExportedHeadersForTarget target) + set_target_properties(${target} + PROPERTIES + FRAMEWORK ON + PUBLIC_HEADER "${ARGN}" + ) +endfunction() diff --git a/CMake/SetVersionForTarget.cmake b/CMake/SetVersionForTarget.cmake new file mode 100644 index 00000000..a4e8531b --- /dev/null +++ b/CMake/SetVersionForTarget.cmake @@ -0,0 +1,7 @@ +function(setVersionForTarget target) + set_target_properties(${target} + PROPERTIES + VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH} + SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR} + ) +endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index 90508935..eb72880e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.16.0) + find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") @@ -149,6 +150,8 @@ if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")) endif() include(CMake/SetWarnings.cmake) +include(CMake/SetVersionForTarget.cmake) +include(CMake/SetCommonTargetProperties.cmake) include(CMake/AddSystemHeadersToTarget.cmake) include(CMake/CopyDllForTarget.cmake) diff --git a/src/OpenVDS/CMakeLists.txt b/src/OpenVDS/CMakeLists.txt index 224b858a..0cc41139 100644 --- a/src/OpenVDS/CMakeLists.txt +++ b/src/OpenVDS/CMakeLists.txt @@ -132,8 +132,6 @@ add_library(openvds_objects OBJECT ${EXPORTED_HEADER_FILES} ${SOURCE_FILES} "IO/IOManagerDms.cpp") -setWarningFlagsForTarget(openvds_objects) - function(compileInTarget to_target source_target) get_target_property(src_sources ${source_target} SOURCES) get_target_property(src_include ${source_target} INTERFACE_INCLUDE_DIRECTORIES) @@ -283,13 +281,11 @@ endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) add_library(openvds $) add_library(openvds::openvds ALIAS openvds) target_link_libraries(openvds PRIVATE openvds_objects) -set_target_properties(openvds - PROPERTIES - FRAMEWORK ON - VERSION ${CMAKE_PROJECT_VERSION} - PUBLIC_HEADER "${EXPORTED_HEADER_FILES}" - #OUTPUT_NAME ${PROJECT_NAME} -) + +setCommonTargetProperties(openvds_objects) +setCommonTargetProperties(openvds) +setExportedHeadersForTarget(openvds ${EXPORTED_HEADER_FILES}) + foreach(item ${link_3rdparty_debug}) target_link_libraries(openvds PRIVATE debug ${item}) endforeach() @@ -346,7 +342,7 @@ export( openvds-config.cmake ) -set(CMAKE_INSTALL_BINDIR}${LIB_TOOLSET_DIR}) +set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${CMAKE_INSTALL_BINDIR}${LIB_TOOLSET_DIR}) include (InstallRequiredSystemLibraries) set(OPENVDS_LIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "") diff --git a/src/SEGYUtils/CMakeLists.txt b/src/SEGYUtils/CMakeLists.txt index 4ba45b5e..791ec538 100644 --- a/src/SEGYUtils/CMakeLists.txt +++ b/src/SEGYUtils/CMakeLists.txt @@ -9,15 +9,8 @@ add_library(segyutils SEGY.cpp SEGYFileInfo.cpp ) -setWarningFlagsForTarget(segyutils) -set_target_properties(segyutils - PROPERTIES - FRAMEWORK ON - VERSION ${CMAKE_PROJECT_VERSION} - PUBLIC_HEADER "${EXPORTED_HEADER_FILES}" - #OUTPUT_NAME ${PROJECT_NAME} -) - +setCommonTargetProperties(segyutils) +setExportedHeadersForTarget(segyutils ${EXPORTED_HEADER_FILES}) target_compile_definitions(segyutils PRIVATE openvds_EXPORTS) target_link_libraries(segyutils PUBLIC openvds) @@ -53,17 +46,14 @@ install(TARGETS segyutils install( EXPORT segyutils-export NAMESPACE segyutils:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/segyutils + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/segyutils FILE segyutils-config.cmake ) -install(FILES ${runtime_3rdparty_release} CONFIGURATIONS Release RelWithDebInfo MinSizeRel DESTINATION ${CMAKE_INSTALL_BINDIR}${LIB_TOOLSET_DIR}) -install(FILES ${runtime_3rdparty_debug} CONFIGURATIONS Debug DESTINATION ${CMAKE_INSTALL_BINDIR}${LIB_TOOLSET_DIR}) +set(RUNTIME_LIBS_DESTINATION $,${CMAKE_INSTALL_BINDIR},${CMAKE_INSTALL_LIBDIR}>${LIB_TOOLSET_DIR}) +install(FILES ${runtime_3rdparty_release} CONFIGURATIONS Release RelWithDebInfo MinSizeRel DESTINATION ${RUNTIME_LIBS_DESTINATION}) +install(FILES ${runtime_3rdparty_debug} CONFIGURATIONS Debug DESTINATION ${RUNTIME_LIBS_DESTINATION}) -if (UNIX) - install(FILES ${link_3rdparty_release} CONFIGURATIONS Release RelWithDebInfo MinSizeRel DESTINATION ${CMAKE_INSTALL_LIBDIR}${LIB_TOOLSET_DIR}) - install(FILES ${link_3rdparty_debug} CONFIGURATIONS Debug DESTINATION ${CMAKE_INSTALL_LIBDIR}${LIB_TOOLSET_DIR}) -endif() export( TARGETS -- GitLab From 738c919651c27a46a0ee12db53f6a2a76f0a89a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 11 Feb 2021 14:55:45 +0100 Subject: [PATCH 031/194] VS2015 fixes --- src/OpenVDS/CMakeLists.txt | 2 +- src/OpenVDS/IO/IOManagerDms.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenVDS/CMakeLists.txt b/src/OpenVDS/CMakeLists.txt index 0cc41139..0c9ede6f 100644 --- a/src/OpenVDS/CMakeLists.txt +++ b/src/OpenVDS/CMakeLists.txt @@ -119,7 +119,7 @@ set (EXPORTED_HEADER_FILES ) if (MSVC) - set(DISABLE_WARNING_FLAG "/w") + set(DISABLE_WARNING_FLAG "/W0 /WX-") else() set(DISABLE_WARNING_FLAG "-w") endif() diff --git a/src/OpenVDS/IO/IOManagerDms.cpp b/src/OpenVDS/IO/IOManagerDms.cpp index 2cb94804..1ca9167d 100644 --- a/src/OpenVDS/IO/IOManagerDms.cpp +++ b/src/OpenVDS/IO/IOManagerDms.cpp @@ -237,7 +237,7 @@ namespace OpenVDS try { m_sdManager.reset(new seismicdrive::SDManager(openOptions.sdAuthorityUrl, openOptions.sdApiKey, openOptions.logLevel)); m_sdManager->setAuthProviderFromString(openOptions.sdToken); - m_dataset.reset(new seismicdrive::SDGenericDataset(m_sdManager.get(), openOptions.datasetPath, openOptions.logLevel)); + m_dataset.reset(new seismicdrive::SDGenericDataset(m_sdManager.get(), openOptions.datasetPath, openOptions.logLevel != 0)); seismicdrive::SDDatasetDisposition disposition = seismicdrive::SDDatasetDisposition::READ_ONLY; switch (accessPatttern) -- GitLab From a43d803cd7e8b945c551d318a6c0e3847c8fa5ea Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Thu, 11 Feb 2021 14:33:02 +0000 Subject: [PATCH 032/194] Enable LTO for release builds and small build fixes --- 3rdparty/BuildDms/CMakeLists.txt | 4 ++++ CMake/SetCommonTargetProperties.cmake | 2 ++ CMake/SetCompilerFlagsForTarget.cmake | 16 ++++++++++++++++ CMake/SetLTOForTarget.cmake | 6 ++++++ CMakeLists.txt | 16 ++-------------- src/OpenVDS/IO/IOManagerAWS.cpp | 2 +- src/OpenVDS/IO/IOManagerCurl.cpp | 3 ++- src/SEGYUtils/SEGYUtils/SEGY.h | 5 +++++ tests/CMakeLists.txt | 2 +- 9 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 CMake/SetCompilerFlagsForTarget.cmake create mode 100644 CMake/SetLTOForTarget.cmake diff --git a/3rdparty/BuildDms/CMakeLists.txt b/3rdparty/BuildDms/CMakeLists.txt index 1eb48e58..fe6a0b83 100644 --- a/3rdparty/BuildDms/CMakeLists.txt +++ b/3rdparty/BuildDms/CMakeLists.txt @@ -1,3 +1,4 @@ + if(WIN32) list(APPEND CMAKE_MODULE_PATH ${dmsCMakeDir}/modules/version_info_win32) endif() @@ -89,6 +90,9 @@ endif() add_library(sdapi SHARED $) target_link_libraries(sdapi PUBLIC sdapi_objects) +setLTOForTarget(sdapi_objects) +setLTOForTarget(sdapi) + if (WIN32) if(DEFINED LIB_VERSION_ON_NAME) set_target_properties(sdapi PROPERTIES diff --git a/CMake/SetCommonTargetProperties.cmake b/CMake/SetCommonTargetProperties.cmake index b9f9d754..3befd505 100644 --- a/CMake/SetCommonTargetProperties.cmake +++ b/CMake/SetCommonTargetProperties.cmake @@ -1,6 +1,8 @@ function(setCommonTargetProperties target) setWarningFlagsForTarget(${target}) setVersionForTarget(${target}) + setLTOForTarget(${target}) + setCompilerFlagsForTarget(${target}) endfunction() function(setExportedHeadersForTarget target) diff --git a/CMake/SetCompilerFlagsForTarget.cmake b/CMake/SetCompilerFlagsForTarget.cmake new file mode 100644 index 00000000..8ba2d930 --- /dev/null +++ b/CMake/SetCompilerFlagsForTarget.cmake @@ -0,0 +1,16 @@ +function(setCompilerFlagsForTarget target) + if (MSVC) + if (MSVC_VERSION GREATER_EQUAL 1910 AND NOT OpenMP_CXX_FOUND) + target_compile_options(${target} PRIVATE /permissive-) + endif() + if(MSVC_VERSION GREATER_EQUAL 1915) + target_compile_options(${target} PRIVATE $<$>:/JMC>) + endif() + else() + target_compile_options(${target} PRIVATE $<$:-s>) + endif() + + if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")) + target_compile_options(${target} PRIVATE -Werror=return-type) + endif() +endfunction() diff --git a/CMake/SetLTOForTarget.cmake b/CMake/SetLTOForTarget.cmake new file mode 100644 index 00000000..d8448b7b --- /dev/null +++ b/CMake/SetLTOForTarget.cmake @@ -0,0 +1,6 @@ +function(setLTOForTarget target) + set_target_properties(${target} + PROPERTIES + INTERPROCEDURAL_OPTIMIZATION_RELEASE ON + ) +endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index eb72880e..927521fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,23 +134,11 @@ find_package(Threads) if (ENABLE_OPENMP) find_package(OpenMP) endif() -if (MSVC) - if (MSVC_VERSION GREATER_EQUAL 1910 AND NOT OpenMP_CXX_FOUND) - add_compile_options(/permissive-) - endif() - if(MSVC_VERSION GREATER_EQUAL 1915) - add_compile_options( /JMC ) - endif() -endif() - -if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")) - add_compile_options(-Werror=return-type) - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") -endif() include(CMake/SetWarnings.cmake) include(CMake/SetVersionForTarget.cmake) +include(CMake/SetLTOForTarget.cmake) +include(CMake/SetCompilerFlagsForTarget.cmake) include(CMake/SetCommonTargetProperties.cmake) include(CMake/AddSystemHeadersToTarget.cmake) include(CMake/CopyDllForTarget.cmake) diff --git a/src/OpenVDS/IO/IOManagerAWS.cpp b/src/OpenVDS/IO/IOManagerAWS.cpp index 8e1acded..a79aefbb 100644 --- a/src/OpenVDS/IO/IOManagerAWS.cpp +++ b/src/OpenVDS/IO/IOManagerAWS.cpp @@ -58,7 +58,7 @@ namespace OpenVDS return std::string(s.begin(), s.end()); } - static char asciitolower(char in) + inline char asciitolower(char in) { if (in <= 'Z' && in >= 'A') return in - ('Z' - 'z'); diff --git a/src/OpenVDS/IO/IOManagerCurl.cpp b/src/OpenVDS/IO/IOManagerCurl.cpp index 544e0be8..07693e8a 100644 --- a/src/OpenVDS/IO/IOManagerCurl.cpp +++ b/src/OpenVDS/IO/IOManagerCurl.cpp @@ -30,7 +30,8 @@ namespace OpenVDS static const bool curl_verbose_output = false; -static char asciitolower(char in) { +inline char asciitolower(char in) +{ if (in <= 'Z' && in >= 'A') return in - ('Z' - 'z'); return in; diff --git a/src/SEGYUtils/SEGYUtils/SEGY.h b/src/SEGYUtils/SEGYUtils/SEGY.h index 8e02b112..37038f63 100644 --- a/src/SEGYUtils/SEGYUtils/SEGY.h +++ b/src/SEGYUtils/SEGYUtils/SEGY.h @@ -15,6 +15,9 @@ ** limitations under the License. ****************************************************************************/ +#ifndef OPENVDS_SEGY_H +#define OPENVDS_SEGY_H + #include #include @@ -321,3 +324,5 @@ OPENVDS_EXPORT bool IsSEGYTypeUnbinned(SEGYType segyType); OPENVDS_EXPORT bool IsSEGYTypeWithGatherOffset(SEGYType segyType); } // end namespace SEGY + +#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c6d377d8..fe877ce1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,7 +26,7 @@ function(add_test_executable name) target_compile_definitions(${name} PRIVATE openvds_EXPORTS) add_dependencies(${name} TestRootTarget) gtest_discover_tests(${name}) - setWarningFlagsForTarget(${name}) + setCommonTargetProperties(${name}) set_target_properties(${name} PROPERTIES FOLDER tests) get_target_property(fmt_INCLUDE fmt::fmt INTERFACE_INCLUDE_DIRECTORIES) get_target_property(json_INCLUDE jsoncpp_lib_static INTERFACE_INCLUDE_DIRECTORIES) -- GitLab From 9ef187cd0cf4bcbd98b6707a362af904b4d6c2d1 Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Fri, 12 Feb 2021 13:36:19 +0000 Subject: [PATCH 033/194] Fixup stripping symbols on non MSVC release builds --- CMake/SetCompilerFlagsForTarget.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/SetCompilerFlagsForTarget.cmake b/CMake/SetCompilerFlagsForTarget.cmake index 8ba2d930..1abf8489 100644 --- a/CMake/SetCompilerFlagsForTarget.cmake +++ b/CMake/SetCompilerFlagsForTarget.cmake @@ -7,7 +7,7 @@ function(setCompilerFlagsForTarget target) target_compile_options(${target} PRIVATE $<$>:/JMC>) endif() else() - target_compile_options(${target} PRIVATE $<$:-s>) + set_target_properties(${target} PROPERTIES LINK_FLAGS_RELEASE -s) endif() if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")) -- GitLab From 46d5051b2c357012fe5dea2d5f64b913b3ae7b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 17 Feb 2021 09:49:34 +0100 Subject: [PATCH 034/194] Fix building cmake generated vs solutions --- CMake/BuildAzure.cmake | 2 +- .../CppRestSdk/Findcpprestsdk.cmake | 31 +++++++++++++++++++ CMake/SetCompilerFlagsForTarget.cmake | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake diff --git a/CMake/BuildAzure.cmake b/CMake/BuildAzure.cmake index ae7e716c..895106e3 100644 --- a/CMake/BuildAzure.cmake +++ b/CMake/BuildAzure.cmake @@ -12,7 +12,7 @@ function(BuildAzure) endif() set(AzureCmakeDir "${azure-storage-cpp_SOURCE_DIR}/Microsoft.WindowsAzure.Storage") if (WIN32) - set(cmake_arg -DCMAKE_PREFIX_PATH=${cpp-rest-api_INSTALL_INT_CONFIG}/lib/cmake) + set(cmake_arg "-Dcpp-rest-api_INSTALL_INT_CONFIG=${cpp-rest-api_INSTALL_INT_CONFIG};-DCMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/CMake/FindPackage/CppRestSdk") else() set(cmake_arg -DCASABLANCA_DIR=${cpp-rest-api_INSTALL_INT_CONFIG}) endif() diff --git a/CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake b/CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake new file mode 100644 index 00000000..4c4cd305 --- /dev/null +++ b/CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake @@ -0,0 +1,31 @@ +set(CPPRESTSDK_INCLUDE_DIRECTORIES ${cpp-rest-api_INSTALL_INT_CONFIG}/include) + +if(WIN32) + if(CMAKE_VS_PLATFORM_TOOLSET) + string(REGEX REPLACE "^v" "" MSVC_TOOLSET_VERSION_LOCAL "${CMAKE_VS_PLATFORM_TOOLSET}") + else() + set(MSVC_TOOLSET_VERSION_LOCAL ${MSVC_TOOLSET_VERSION}) + endif() +endif() + +set(CPPRESTSDK_IMPL_LIB_RELEASE ${cpp-rest-api_INSTALL_INT_CONFIG}/lib/cpprest${MSVC_TOOLSET_VERSION_LOCAL}_2_10.lib) +set(CPPRESTSDK_IMPL_LIB_DEBUG ${cpp-rest-api_INSTALL_INT_CONFIG}/lib/cpprest${MSVC_TOOLSET_VERSION_LOCAL}_2_10d.lib) + +set(CPPRESTSDK_LOCATION_RELEASE ${cpp-rest-api_INSTALL_INT_CONFIG}/bin/cpprest${MSVC_TOOLSET_VERSION_LOCAL}_2_10.dll) +set(CPPRESTSDK_LOCATION_DEBUG ${cpp-rest-api_INSTALL_INT_CONFIG}/bin/cpprest${MSVC_TOOLSET_VERSION_LOCAL}_2_10d.dll) + +if (NOT TARGET cpprestsdk::cpprest) + add_library(cpprestsdk::cpprest SHARED IMPORTED) + set_target_properties(cpprestsdk::cpprest + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CPPRESTSDK_INCLUDE_DIRECTORIES}" + IMPORTED_IMPLIB_RELEASE "${CPPRESTSDK_IMPL_LIB_RELEASE}" + IMPORTED_IMPLIB_DEBUG "${CPPRESTSDK_IMPL_LIB_DEBUG}" + IMPORTED_LOCATION_RELEASE "${CPPRESTSDK_LOCATION_RELEASE}" + IMPORTED_LOCATION_DEBUG "${CPPRESTSDK_LOCATION_DEBUG}" + MAP_IMPORTED_CONFIG_MINSIZEREL Release + MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release + ) +endif() + +set(cpprestsdk_FOUND ON) diff --git a/CMake/SetCompilerFlagsForTarget.cmake b/CMake/SetCompilerFlagsForTarget.cmake index 1abf8489..41fdf142 100644 --- a/CMake/SetCompilerFlagsForTarget.cmake +++ b/CMake/SetCompilerFlagsForTarget.cmake @@ -6,6 +6,7 @@ function(setCompilerFlagsForTarget target) if(MSVC_VERSION GREATER_EQUAL 1915) target_compile_options(${target} PRIVATE $<$>:/JMC>) endif() + target_compile_options(${target} PRIVATE /MP) else() set_target_properties(${target} PROPERTIES LINK_FLAGS_RELEASE -s) endif() -- GitLab From c5a34646a212dbfeb8f43796abc8ecebaf6a9561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 18 Feb 2021 12:00:17 +0100 Subject: [PATCH 035/194] Make it possible to inspect if a protocol is known --- src/OpenVDS/OpenVDS.cpp | 90 +++++++++++++++++++---------------- src/OpenVDS/OpenVDS/OpenVDS.h | 15 ++++++ 2 files changed, 64 insertions(+), 41 deletions(-) diff --git a/src/OpenVDS/OpenVDS.cpp b/src/OpenVDS/OpenVDS.cpp index ca11e267..2ebdcb0c 100644 --- a/src/OpenVDS/OpenVDS.cpp +++ b/src/OpenVDS/OpenVDS.cpp @@ -49,22 +49,20 @@ OpenOptions::~OpenOptions() } -template -static bool isProtocol(const StringWrapper &str, const char(&literal)[SIZE]) +static bool isProtocol(const StringWrapper &str, const StringWrapper &literal) { - if (str.size < SIZE - 1) + if (str.size < literal.size) return false; - std::string protocol(str.data, str.data + SIZE - 1); + std::string protocol(str.data, str.data + literal.size); std::transform(protocol.begin(), protocol.end(), protocol.begin(), asciitolower); - return memcmp(protocol.data(), literal, SIZE - 1) == 0; + return memcmp(protocol.data(), literal.data, literal.size) == 0; } -template -static StringWrapper removeProtocol(const StringWrapper& str, const char(&literal)[SIZE]) +static StringWrapper removeProtocol(const StringWrapper& str, const StringWrapper &literal) { StringWrapper ret(str); - ret.data += SIZE - 1; - ret.size -= SIZE - 1; + ret.data += literal.size; + ret.size -= literal.size; return ret; } @@ -390,55 +388,65 @@ static std::unique_ptr createInMemoryOpenOptions(const StringWrappe return openOptions; } +typedef StringWrapper (*UrlTransformer)(const StringWrapper &url, const StringWrapper &transformer); +typedef std::unique_ptr(*OpenOptionsCreator)(const StringWrapper& url, const StringWrapper& connectionString, Error& error); +struct UrlToOpenOptions +{ + std::string protocol; + UrlTransformer transformer; + OpenOptionsCreator creator; +}; + +static const std::vector urlToOpenOptions = { + {std::string("s3://"), &removeProtocol, &createS3OpenOptions }, + {std::string("az://"), &removeProtocol, &createAzureOpenOptions }, + {std::string("azure://"), &removeProtocol, &createAzureOpenOptions }, + {std::string("azuresas://"), &removeProtocol, &createAzureSASOpenOptions }, + {std::string("gs://"), &removeProtocol, &createGoogleOpenOptions }, + {std::string("sd://"), nullptr, &createDMSOpenOptions }, + {std::string("http://"), nullptr, &createHttpOpenOptions }, + {std::string("https://"), nullptr, &createHttpOpenOptions }, + {std::string("file://"), nullptr, &createVDSFileOpenOptions }, + {std::string("inmemory://"), &removeProtocol, &createInMemoryOpenOptions} +}; + OpenOptions* CreateOpenOptions(StringWrapper url, StringWrapper connectionString, Error& error) { error = Error(); std::unique_ptr openOptions; - if (isProtocol(url, "s3://")) - { - openOptions = createS3OpenOptions(removeProtocol(url, "s3://"), connectionString, error); - } - else if (isProtocol(url, "azure://")) - { - openOptions = createAzureOpenOptions(removeProtocol(url, "azure://"), connectionString, error); - } - else if (isProtocol(url, "azuresas://")) - { - openOptions = createAzureSASOpenOptions(removeProtocol(url, "azuresas://"), connectionString, error); - } - else if (isProtocol(url, "gs://")) - { - openOptions = createGoogleOpenOptions(removeProtocol(url, "gs://"), connectionString, error); - } - else if (isProtocol(url, "sd://")) - { - openOptions = createDMSOpenOptions(url, connectionString, error); - } - else if (isProtocol(url, "http://") || isProtocol(url, "https://")) - { - openOptions = createHttpOpenOptions(url, connectionString, error); - } - else if (isProtocol(url, "file://")) + for (auto& urlToOpenOption : urlToOpenOptions) { - openOptions = createVDSFileOpenOptions(removeProtocol(url, "file://"), connectionString, error); + if (!isProtocol(url, urlToOpenOption.protocol)) + continue; + auto transformed_url = urlToOpenOption.transformer ? urlToOpenOption.transformer(url, urlToOpenOption.protocol) : url; + openOptions = urlToOpenOption.creator(transformed_url, connectionString, error); + break; } - else if (isProtocol(url, "inmemory://")) + + if (error.code) { - openOptions = createInMemoryOpenOptions(removeProtocol(url, "inmemory://"), connectionString, error); + return nullptr; } - else + + if (!openOptions) { error.code = -1; error.string = fmt::format("Unknown url scheme for {}.", std::string(url.data, url.data + url.size)); return nullptr; } - if (error.code) + return openOptions.release(); +} + +bool IsSupportedProtocol(StringWrapper url) +{ + for (auto& urlToOpenOpiton : urlToOpenOptions) { - return nullptr; + if (isProtocol(url, urlToOpenOpiton.protocol)) + return true; } - return openOptions.release(); + return false; } VDSHandle Open(StringWrapper url, StringWrapper connectionString, Error& error) diff --git a/src/OpenVDS/OpenVDS/OpenVDS.h b/src/OpenVDS/OpenVDS/OpenVDS.h index 4f1b68a8..9efde477 100644 --- a/src/OpenVDS/OpenVDS/OpenVDS.h +++ b/src/OpenVDS/OpenVDS/OpenVDS.h @@ -535,6 +535,13 @@ struct StringWrapper , size(toWrap.size()) {} + template + StringWrapper(const char(&toWrap)[SIZE]) + : data(toWrap) + , size(SIZE - 1) + { + } + const char* data; size_t size; }; @@ -565,6 +572,14 @@ class VolumeDataPageAccessor; /// OPENVDS_EXPORT OpenOptions* CreateOpenOptions(StringWrapper url, StringWrapper connectionString, Error& error); +/// +/// Verifies that the url is a supported protocol +/// +/// +/// Returnes true if the protocol specifier of the url is recognised by OpenVDS, otherwise returns false +/// +OPENVDS_EXPORT bool IsSupportedProtocol(StringWrapper url); + /// /// Open an existing VDS /// -- GitLab From b3e6d9e1ecd78e62e304879d04d04fc3a937b7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 18 Feb 2021 12:47:00 +0100 Subject: [PATCH 036/194] Use same toolset logic as cpprestsdk in find cmake --- CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake b/CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake index 4c4cd305..6a55eb73 100644 --- a/CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake +++ b/CMake/FindPackage/CppRestSdk/Findcpprestsdk.cmake @@ -1,18 +1,17 @@ set(CPPRESTSDK_INCLUDE_DIRECTORIES ${cpp-rest-api_INSTALL_INT_CONFIG}/include) if(WIN32) + set(TOOLSET) if(CMAKE_VS_PLATFORM_TOOLSET) - string(REGEX REPLACE "^v" "" MSVC_TOOLSET_VERSION_LOCAL "${CMAKE_VS_PLATFORM_TOOLSET}") - else() - set(MSVC_TOOLSET_VERSION_LOCAL ${MSVC_TOOLSET_VERSION}) + string(REGEX REPLACE "^v" "" TOOLSET "${CMAKE_VS_PLATFORM_TOOLSET}") endif() endif() -set(CPPRESTSDK_IMPL_LIB_RELEASE ${cpp-rest-api_INSTALL_INT_CONFIG}/lib/cpprest${MSVC_TOOLSET_VERSION_LOCAL}_2_10.lib) -set(CPPRESTSDK_IMPL_LIB_DEBUG ${cpp-rest-api_INSTALL_INT_CONFIG}/lib/cpprest${MSVC_TOOLSET_VERSION_LOCAL}_2_10d.lib) +set(CPPRESTSDK_IMPL_LIB_RELEASE ${cpp-rest-api_INSTALL_INT_CONFIG}/lib/cpprest${TOOLSET}_2_10.lib) +set(CPPRESTSDK_IMPL_LIB_DEBUG ${cpp-rest-api_INSTALL_INT_CONFIG}/lib/cpprest${TOOLSET}_2_10d.lib) -set(CPPRESTSDK_LOCATION_RELEASE ${cpp-rest-api_INSTALL_INT_CONFIG}/bin/cpprest${MSVC_TOOLSET_VERSION_LOCAL}_2_10.dll) -set(CPPRESTSDK_LOCATION_DEBUG ${cpp-rest-api_INSTALL_INT_CONFIG}/bin/cpprest${MSVC_TOOLSET_VERSION_LOCAL}_2_10d.dll) +set(CPPRESTSDK_LOCATION_RELEASE ${cpp-rest-api_INSTALL_INT_CONFIG}/bin/cpprest${TOOLSET}_2_10.dll) +set(CPPRESTSDK_LOCATION_DEBUG ${cpp-rest-api_INSTALL_INT_CONFIG}/bin/cpprest${TOOLSET}_2_10d.dll) if (NOT TARGET cpprestsdk::cpprest) add_library(cpprestsdk::cpprest SHARED IMPORTED) -- GitLab From c00b85ec1dbbd86ecf516f8aa192a40f890aed5b Mon Sep 17 00:00:00 2001 From: "morten.ofstad" Date: Fri, 12 Feb 2021 10:47:04 +0100 Subject: [PATCH 037/194] New VolumeDataAccessManager (missing Python bindings). --- docs/getting-started.rst | 17 +- examples/GettingStarted/main.cpp | 13 +- examples/SliceDump/GenerateVDS.h | 18 +- examples/SliceDump/main.cpp | 12 +- java/cpp/src/MemoryVdsGenerator.cpp | 18 +- java/cpp/src/OpenVDSJava.cpp | 2 +- java/cpp/src/VdsHandle.cpp | 2 +- java/cpp/src/VolumeDataAccessManager.cpp | 118 +- java/cpp/src/WriteVolumeData.cpp | 20 +- java/java/demo/AWSSliceDumpDemo.java | 2 +- java/java/demo/OpenVdsDemo.java | 2 +- .../openvds/VolumeDataAccessManager.java | 49 +- .../org/opengroup/openvds/AmazonS3Test.java | 18 +- .../org/opengroup/openvds/CreateVDSTest.java | 2 +- .../openvds/MemoryVdsGeneratorTest.java | 114 +- .../org/opengroup/openvds/WriteDataTest.java | 10 +- python/openvds/CMakeLists.txt | 2 + python/openvds/PyGlobal.cpp | 3 +- python/openvds/PyVolumeDataAccess.cpp | 109 +- python/openvds/PyVolumeDataAccessManager.cpp | 407 +++ python/openvds/PyVolumeDataAccessManager.h | 28 + python/openvds/core.cpp | 2 + python/openvds/generated_docstrings.h | 1823 ++++++++++--- src/OpenVDS/CMakeLists.txt | 1 - src/OpenVDS/OpenVDS.cpp | 7 +- src/OpenVDS/OpenVDS/Exceptions.h | 98 + src/OpenVDS/OpenVDS/OpenVDS.h | 19 +- src/OpenVDS/OpenVDS/Optional.h | 81 + src/OpenVDS/OpenVDS/VolumeDataAccess.h | 804 ++---- src/OpenVDS/OpenVDS/VolumeDataAccessManager.h | 2349 +++++++++++++++++ src/OpenVDS/OpenVDS/VolumeSampler.h | 8 +- src/OpenVDS/VDS/VDS.h | 4 +- .../VDS/VolumeDataAccessManagerImpl.cpp | 563 +++- src/OpenVDS/VDS/VolumeDataAccessManagerImpl.h | 125 +- src/OpenVDS/VDS/VolumeDataAccessor.cpp | 95 +- src/OpenVDS/VDS/VolumeDataAccessor.h | 86 +- src/OpenVDS/VDS/VolumeDataAccessorRequest.cpp | 1827 ------------- .../VDS/VolumeDataPageAccessorImpl.cpp | 2 +- src/OpenVDS/VDS/VolumeDataPageAccessorImpl.h | 4 +- src/OpenVDS/VDS/VolumeDataPageImpl.cpp | 3 +- src/OpenVDS/VDS/VolumeDataPageImpl.h | 2 +- .../VDS/VolumeDataRequestProcessor.cpp | 1698 +++++++++++- src/OpenVDS/VDS/VolumeDataRequestProcessor.h | 13 + tests/OpenVDS/DataAccess.cpp | 36 +- tests/OpenVDS/DataAccessorClone.cpp | 12 +- tests/OpenVDS/GlobalStateTest.cpp | 10 +- tests/OpenVDS/MultiThreadedRequests.cpp | 10 +- tests/OpenVDS/RequestCancellation.cpp | 21 +- tests/OpenVDS/RequestVolumeError.cpp | 13 +- tests/OpenVDS/RequestVolumeSamples.cpp | 20 +- .../RequestVolumeSubsetAndPageAccessor.cpp | 15 +- tests/OpenVDS/RequestVolumeSubsetFormat.cpp | 37 +- tests/OpenVDS/RequestVolumeTraces.cpp | 17 +- tests/OpenVDS/WaitForCompletion.cpp | 12 +- tests/VDS/RequestVolumeCleanupThread.cpp | 9 +- tests/io/InMemoryIo.cpp | 7 +- tests/io/IoErrorHandling.cpp | 81 +- tests/io/IoVDSRoundtrip.cpp | 62 +- tests/utils/GenerateVDS.h | 18 +- tools/SEGYExport/SEGYExport.cpp | 40 +- tools/SEGYImport/SEGYImport.cpp | 14 +- 61 files changed, 7414 insertions(+), 3600 deletions(-) create mode 100644 python/openvds/PyVolumeDataAccessManager.cpp create mode 100644 python/openvds/PyVolumeDataAccessManager.h create mode 100644 src/OpenVDS/OpenVDS/Exceptions.h create mode 100644 src/OpenVDS/OpenVDS/Optional.h create mode 100644 src/OpenVDS/OpenVDS/VolumeDataAccessManager.h delete mode 100644 src/OpenVDS/VDS/VolumeDataAccessorRequest.cpp diff --git a/docs/getting-started.rst b/docs/getting-started.rst index 1fd24920..7ebcf332 100644 --- a/docs/getting-started.rst +++ b/docs/getting-started.rst @@ -58,8 +58,8 @@ If everything went well we can now get the :cpp:class:`VolumeDataAccessManager` .. code-block:: cpp - OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(handle); - OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(handle); + OpenVDS::VolumeDataAccessManager accessManager = OpenVDS::GetAccessManager(handle); + OpenVDS::VolumeDataLayout const *layout = accessManager.GetVolumeDataLayout(); Using the VolumeDataLayout ------------- @@ -90,18 +90,25 @@ To request data we need to set up the index region that we want to read: voxelMin[inlineDimension] = inlineIndex; voxelMax[inlineDimension] = inlineIndex + 1; -Then we can make the request for data: +Then we can make the request for data, the data is automatically converted to the type of the buffer (there is also an overload with a void-pointer and a format): .. code-block:: cpp std::vector buffer(layout->GetDimensionNumSamples(sampleDimension) * layout->GetDimensionNumSamples(crosslineDimension)); - int64_t iRequestID = accessManager->RequestVolumeSubset(buffer.data(), layout, OpenVDS::Dimensions_012, 0, 0, voxelMin, voxelMax, OpenVDS::VolumeDataChannelDescriptor::Format_R32); + auto request = accessManager.RequestVolumeSubset(buffer.data(), buffer.size() * sizeof(float), OpenVDS::Dimensions_012, 0, 0, voxelMin, voxelMax); Because all requests in OpenVDS are asynchronous we need to wait for the request to complete before we can access the data in the buffer: .. code-block:: cpp - bool success = accessManager->WaitForCompletion(iRequestID); + bool success = request->WaitForCompletion(); + +Alternatively you can let OpenVDS allocate the buffer for you, getting the data will block until the request has completed or throw an exception: + +.. code-block:: cpp + + auto request = accessManager.RequestVolumeSubset(OpenVDS::Dimensions_012, 0, 0, voxelMin, voxelMax); + std::vector data = std::move(request->Data()); The complete code for this tutorial can be found in examples/GettingStarted. diff --git a/examples/GettingStarted/main.cpp b/examples/GettingStarted/main.cpp index 25a1464d..cf417d8f 100644 --- a/examples/GettingStarted/main.cpp +++ b/examples/GettingStarted/main.cpp @@ -18,8 +18,8 @@ int main(int argc, char *argv[]) exit(1); } - OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(handle); - OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(handle); + OpenVDS::VolumeDataAccessManager accessManager = OpenVDS::GetAccessManager(handle); + OpenVDS::VolumeDataLayout const *layout = accessManager.GetVolumeDataLayout(); const int sampleDimension = 0, crosslineDimension = 1, inlineDimension = 2; OpenVDS::VolumeDataAxisDescriptor inlineAxisDescriptor = layout->GetAxisDescriptor(inlineDimension); @@ -38,8 +38,13 @@ int main(int argc, char *argv[]) std::vector buffer(layout->GetDimensionNumSamples(sampleDimension) * layout->GetDimensionNumSamples(crosslineDimension)); - int64_t iRequestID = accessManager->RequestVolumeSubset(buffer.data(), layout, OpenVDS::Dimensions_012, 0, 0, voxelMin, voxelMax, OpenVDS::VolumeDataChannelDescriptor::Format_R32); + auto request = accessManager.RequestVolumeSubset(buffer.data(), buffer.size() * sizeof(float), OpenVDS::Dimensions_012, 0, 0, voxelMin, voxelMax); - bool success = accessManager->WaitForCompletion(iRequestID); + bool success = request->WaitForCompletion(); (void)success; + + { + auto request = accessManager.RequestVolumeSubset(OpenVDS::Dimensions_012, 0, 0, voxelMin, voxelMax); + std::vector data = std::move(request->Data()); + } } diff --git a/examples/SliceDump/GenerateVDS.h b/examples/SliceDump/GenerateVDS.h index 1ae228ca..807459ea 100644 --- a/examples/SliceDump/GenerateVDS.h +++ b/examples/SliceDump/GenerateVDS.h @@ -67,10 +67,9 @@ inline void fill3DVDSWithNoise(OpenVDS::VDS *vds, int32_t channel = 0, const Ope { OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(vds); //ASSERT_TRUE(layout); - OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(vds); - //ASSERT_TRUE(accessManager); + OpenVDS::VolumeDataAccessManager accessManager = OpenVDS::GetAccessManager(vds); - OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); + OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager.CreateVolumeDataPageAccessor(OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); //ASSERT_TRUE(pageAccessor); int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); @@ -89,8 +88,8 @@ inline void fill3DVDSWithNoise(OpenVDS::VDS *vds, int32_t channel = 0, const Ope } pageAccessor->Commit(); pageAccessor->SetMaxPages(0); - accessManager->FlushUploadQueue(); - accessManager->DestroyVolumeDataPageAccessor(pageAccessor); + accessManager.FlushUploadQueue(); + accessManager.DestroyVolumeDataPageAccessor(pageAccessor); } @@ -98,10 +97,9 @@ inline void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0) { OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(vds); //ASSERT_TRUE(layout); - OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(vds); - //ASSERT_TRUE(accessManager); + OpenVDS::VolumeDataAccessManager accessManager = OpenVDS::GetAccessManager(vds); - OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); + OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager.CreateVolumeDataPageAccessor(OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); //ASSERT_TRUE(pageAccessor); int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); @@ -145,7 +143,7 @@ inline void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0) } pageAccessor->Commit(); pageAccessor->SetMaxPages(0); - accessManager->FlushUploadQueue(); - accessManager->DestroyVolumeDataPageAccessor(pageAccessor); + accessManager.FlushUploadQueue(); + accessManager.DestroyVolumeDataPageAccessor(pageAccessor); } diff --git a/examples/SliceDump/main.cpp b/examples/SliceDump/main.cpp index e61bef2d..5ac93709 100644 --- a/examples/SliceDump/main.cpp +++ b/examples/SliceDump/main.cpp @@ -156,7 +156,7 @@ int main(int argc, char **argv) } OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(handle); - OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(handle); + OpenVDS::VolumeDataAccessManager accessManager = OpenVDS::GetAccessManager(handle); int sampleCount[3]; sampleCount[0] = layout->GetDimensionNumSamples(axis_mapper[0]); @@ -187,16 +187,13 @@ int main(int argc, char **argv) } } - std::vector data; - data.resize(size_t(output_width) * size_t(output_height)); - - int64_t request = accessManager->RequestVolumeSamples(data.data(), layout, OpenVDS::Dimensions_012, 0, 0, reinterpret_cast(samples.data()), (int)samples.size(), OpenVDS::InterpolationMethod::Linear); - bool finished = accessManager->WaitForCompletion(request); + auto request = accessManager.RequestVolumeSamples(OpenVDS::Dimensions_012, 0, 0, reinterpret_cast(samples.data()), (int)samples.size(), OpenVDS::InterpolationMethod::Linear); + bool finished = request->WaitForCompletion(); if (!finished) { int code; const char* errorstr; - accessManager->GetCurrentDownloadError(&code, &errorstr); + accessManager.GetCurrentDownloadError(&code, &errorstr); fprintf(stderr, "Failed to download request: %d - %s\n", code, errorstr); return -2; } @@ -207,6 +204,7 @@ int main(int argc, char **argv) float intLayout = layout->GetChannelIntegerOffset(0); OpenVDS::QuantizingValueConverterWithNoValue converter(minValue, maxValue, intScale, intLayout, 0.f, 0.f); + std::vector data = std::move(request->Data()); std::vector> fileData; fileData.resize(size_t(output_width) * size_t(output_height)); for (int y = 0; y < output_height; y++) diff --git a/java/cpp/src/MemoryVdsGenerator.cpp b/java/cpp/src/MemoryVdsGenerator.cpp index c276454d..37d7c0a2 100644 --- a/java/cpp/src/MemoryVdsGenerator.cpp +++ b/java/cpp/src/MemoryVdsGenerator.cpp @@ -109,10 +109,9 @@ static void fill3DVDSWithNoise(OpenVDS::VDS *vds, int32_t channel = 0, const Ope { OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(vds); //ASSERT_TRUE(layout); - OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(vds); - //ASSERT_TRUE(accessManager); + OpenVDS::VolumeDataAccessManager accessManager = OpenVDS::GetAccessManager(vds); - OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); + OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager.CreateVolumeDataPageAccessor(OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); //ASSERT_TRUE(pageAccessor); int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); @@ -131,8 +130,8 @@ static void fill3DVDSWithNoise(OpenVDS::VDS *vds, int32_t channel = 0, const Ope } pageAccessor->Commit(); pageAccessor->SetMaxPages(0); - accessManager->FlushUploadQueue(); - accessManager->DestroyVolumeDataPageAccessor(pageAccessor); + accessManager.FlushUploadQueue(); + accessManager.DestroyVolumeDataPageAccessor(pageAccessor); } @@ -140,10 +139,9 @@ static void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0) { OpenVDS::VolumeDataLayout *layout = OpenVDS::GetLayout(vds); //ASSERT_TRUE(layout); - OpenVDS::VolumeDataAccessManager *accessManager = OpenVDS::GetAccessManager(vds); - //ASSERT_TRUE(accessManager); + OpenVDS::VolumeDataAccessManager accessManager = OpenVDS::GetAccessManager(vds); - OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); + OpenVDS::VolumeDataPageAccessor *pageAccessor = accessManager.CreateVolumeDataPageAccessor(OpenVDS::Dimensions_012, channel, 0, 100, OpenVDS::VolumeDataAccessManager::AccessMode_Create); //ASSERT_TRUE(pageAccessor); int32_t chunkCount = int32_t(pageAccessor->GetChunkCount()); @@ -187,8 +185,8 @@ static void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0) } pageAccessor->Commit(); pageAccessor->SetMaxPages(0); - accessManager->FlushUploadQueue(); - accessManager->DestroyVolumeDataPageAccessor(pageAccessor); + accessManager.FlushUploadQueue(); + accessManager.DestroyVolumeDataPageAccessor(pageAccessor); } diff --git a/java/cpp/src/OpenVDSJava.cpp b/java/cpp/src/OpenVDSJava.cpp index 40dc5d23..3a589895 100644 --- a/java/cpp/src/OpenVDSJava.cpp +++ b/java/cpp/src/OpenVDSJava.cpp @@ -147,7 +147,7 @@ getVolumeDataChannelDescriptor(JNIEnv *env, jobjectArray obj, std::multisetCallObjectMethod(element, env->GetMethodID(elm_class, "getUnit", "()Ljava/lang/String;")))); float valuerangemin = env->CallFloatMethod(element, env->GetMethodID(elm_class, "getValueRangeMin", "()F")); float valuerangemax = env->CallFloatMethod(element, env->GetMethodID(elm_class, "getValueRangeMax", "()F")); - long mapping = env->CallLongMethod(element, env->GetMethodID(elm_class, "getMapping", "()J")); + uint64_t mapping = env->CallLongMethod(element, env->GetMethodID(elm_class, "getMapping", "()J")); int mappedvaluecount = env->CallIntMethod(element, env->GetMethodID(elm_class, "getMappedValueCount", "()I")); bool isdiscrete = env->CallBooleanMethod(element, env->GetMethodID(elm_class, "isDiscrete", "()Z")); bool isrenderable = env->CallBooleanMethod(element, env->GetMethodID(elm_class, "isRenderable", "()Z")); diff --git a/java/cpp/src/VdsHandle.cpp b/java/cpp/src/VdsHandle.cpp index dfabbae6..01b099ca 100644 --- a/java/cpp/src/VdsHandle.cpp +++ b/java/cpp/src/VdsHandle.cpp @@ -67,7 +67,7 @@ extern "C" { ( JNIEnv *env, jclass, jlong handle ) { try { - return (jlong)OpenVDS::GetAccessManager( GetVds( handle ) ); + return (jlong)OpenVDS::GetAccessManagerInterface( GetVds( handle ) ); } CATCH_EXCEPTIONS_FOR_JAVA; return 0; diff --git a/java/cpp/src/VolumeDataAccessManager.cpp b/java/cpp/src/VolumeDataAccessManager.cpp index 0f51597e..0755841b 100644 --- a/java/cpp/src/VolumeDataAccessManager.cpp +++ b/java/cpp/src/VolumeDataAccessManager.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include @@ -30,8 +30,8 @@ typedef int Voxel[Dimensionality_Max]; extern "C" { #endif -inline OpenVDS::VolumeDataAccessManager *GetManager(jlong handle) { - return (OpenVDS::VolumeDataAccessManager *) CheckHandle(handle); +inline OpenVDS::IVolumeDataAccessManager *GetManager(jlong handle) { + return (OpenVDS::IVolumeDataAccessManager *) CheckHandle(handle); } inline OpenVDS::VolumeDataLayout *GetLayout(jlong handle) { @@ -42,8 +42,8 @@ inline OpenVDS::VolumeDataPageAccessor *GetPageAccessor(jlong handle) { return (OpenVDS::VolumeDataPageAccessor *) CheckHandle(handle); } -inline OpenVDS::VolumeDataAccessor *GetDataAccessor(jlong handle) { - return (OpenVDS::VolumeDataAccessor *) CheckHandle(handle); +inline OpenVDS::IVolumeDataAccessor *GetDataAccessor(jlong handle) { + return (OpenVDS::IVolumeDataAccessor *) CheckHandle(handle); } /* @@ -63,12 +63,12 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGet /* * Class: org_opengroup_openvds_VolumeDataAccessManager * Method: cpGetVDSProduceStatus -* Signature: (JJIII)I +* Signature: (JIII)I */ JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGetVDSProduceStatus - (JNIEnv *env, jclass, jlong handle, jlong layoutHandle, jint dimensionsND, jint lod, jint channel) { + (JNIEnv *env, jclass, jlong handle, jint dimensionsND, jint lod, jint channel) { try { - return (jint) GetManager(handle)->GetVDSProduceStatus(GetLayout(layoutHandle), (DimensionsND) dimensionsND, lod, + return (jint) GetManager(handle)->GetVDSProduceStatus((DimensionsND) dimensionsND, lod, channel); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -78,16 +78,15 @@ JNIEXPORT jint JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGetV /* * Class: org_opengroup_openvds_VolumeDataAccessManager * Method: cpCreateVolumeDataPageAccessor -* Signature: (JJIIIII)J +* Signature: (JIIIII)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpCreateVolumeDataPageAccessor__JJIIIII - (JNIEnv *env, jclass, jlong managerHandle, jlong layoutHandle, jint dimensionsND, jint lod, jint channel, + (JNIEnv *env, jclass, jlong managerHandle, jint dimensionsND, jint lod, jint channel, jint maxPages, jint accessMode) { try { - return (jlong) GetManager(managerHandle)->CreateVolumeDataPageAccessor(GetLayout(layoutHandle), - (DimensionsND) (dimensionsND), lod, + return (jlong) GetManager(managerHandle)->CreateVolumeDataPageAccessor((DimensionsND) (dimensionsND), lod, channel, maxPages, - (VolumeDataAccessManager::AccessMode) accessMode); + (IVolumeDataAccessManager::AccessMode) accessMode); } CATCH_EXCEPTIONS_FOR_JAVA; return 0; @@ -96,16 +95,15 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpCre /* * Class: org_opengroup_openvds_VolumeDataAccessManager * Method: cpCreateVolumeDataPageAccessor -* Signature: (JJIIIIII)J +* Signature: (JIIIIII)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpCreateVolumeDataPageAccessor__JJIIIIII - (JNIEnv *env, jclass, jlong managerHandle, jlong layoutHandle, jint dimensionsND, jint lod, jint channel, + (JNIEnv *env, jclass, jlong managerHandle, jint dimensionsND, jint lod, jint channel, jint maxPages, jint accessMode, jint chunkMetadataPageSize) { try { - return (jlong) GetManager(managerHandle)->CreateVolumeDataPageAccessor(GetLayout(layoutHandle), - (DimensionsND) (dimensionsND), lod, + return (jlong) GetManager(managerHandle)->CreateVolumeDataPageAccessor((DimensionsND) (dimensionsND), lod, channel, maxPages, - (VolumeDataAccessManager::AccessMode) accessMode, chunkMetadataPageSize); + (IVolumeDataAccessManager::AccessMode) accessMode, chunkMetadataPageSize); } CATCH_EXCEPTIONS_FOR_JAVA; return 0; @@ -154,16 +152,15 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpClo /* * Class: org_opengroup_openvds_VolumeDataAccessManager * Method: cpGetVolumeSubsetBufferSize -* Signature: (JJ[I[IIII)J +* Signature: (J[I[IIII)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGetVolumeSubsetBufferSize - (JNIEnv *env, jclass, jlong managerHandle, jlong layoutHandle, jintArray minVoxelCoordinates, + (JNIEnv *env, jclass, jlong managerHandle, jintArray minVoxelCoordinates, jintArray maxVoxelCoordinates, jint format, jint lod, jint channel) { try { std::vector minVoxel = JArrayToVector(env, minVoxelCoordinates); std::vector maxVoxel = JArrayToVector(env, maxVoxelCoordinates); - return GetManager(managerHandle)->GetVolumeSubsetBufferSize(GetLayout(layoutHandle), - (Voxel &) *minVoxel.data(), + return GetManager(managerHandle)->GetVolumeSubsetBufferSize((Voxel &) *minVoxel.data(), (Voxel &) *maxVoxel.data(), (VolumeDataChannelDescriptor::Format) format, lod, channel); } @@ -177,17 +174,15 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGet * Signature: (JLjava/nio/Buffer;JIII[I[II)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpRequestVolumeSubset - (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong layoutHandle, + (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong sampleBufferSize, jint dimensionsND, jint lod, jint channel, jintArray minVoxelCoordinates, jintArray maxVoxelCoordinates, jint formatCode){ std::vector minVoxel = JArrayToVector(env, minVoxelCoordinates); std::vector maxVoxel = JArrayToVector(env, maxVoxelCoordinates); auto output = static_cast(env->GetDirectBufferAddress(jsampleBuffer)); - VolumeDataAccessManager *pManager = GetManager(managerHandle); - VolumeDataLayout *layout = GetLayout(layoutHandle); + IVolumeDataAccessManager *pManager = GetManager(managerHandle); try { - return pManager->RequestVolumeSubset(output, - layout, + return pManager->RequestVolumeSubset(output, sampleBufferSize, (DimensionsND) dimensionsND, lod, channel, (Voxel &) *minVoxel.data(), @@ -204,17 +199,15 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq * Signature: (JLjava/nio/Buffer;JIII[I[IIF)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpRequestVolumeSubsetR - (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong layoutHandle, + (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong sampleBufferSize, jint dimensionsND, jint lod, jint channel, jintArray minVoxelCoordinates, jintArray maxVoxelCoordinates, jint formatCode, jfloat replacementValue) { std::vector minVoxel = JArrayToVector(env, minVoxelCoordinates); std::vector maxVoxel = JArrayToVector(env, maxVoxelCoordinates); auto output = static_cast(env->GetDirectBufferAddress(jsampleBuffer)); - VolumeDataAccessManager *pManager = GetManager(managerHandle); - VolumeDataLayout *layout = GetLayout(layoutHandle); + IVolumeDataAccessManager *pManager = GetManager(managerHandle); try { - return pManager->RequestVolumeSubset(output, - layout, + return pManager->RequestVolumeSubset(output, sampleBufferSize, (DimensionsND) dimensionsND, lod, channel, (Voxel &) *minVoxel.data(), @@ -229,17 +222,16 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq /* * Class: org_opengroup_openvds_VolumeDataAccessManager * Method: cpGetProjectedVolumeSubsetBufferSize -* Signature: (JJ[I[IIIII)J +* Signature: (J[I[IIIII)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGetProjectedVolumeSubsetBufferSize - (JNIEnv *env, jclass, jlong managerHandle, jlong layoutHandle, jintArray minVoxelCoordinates, + (JNIEnv *env, jclass, jlong managerHandle, jintArray minVoxelCoordinates, jintArray maxVoxelCoordinates, jint projectedDimensions, jint format, jint lod, jint channel) { try { std::vector minVoxelArray = JArrayToVector(env, minVoxelCoordinates); std::vector maxVoxelArray = JArrayToVector(env, maxVoxelCoordinates); - return GetManager(managerHandle)->GetProjectedVolumeSubsetBufferSize(GetLayout(layoutHandle), - (Voxel &) *minVoxelArray.data(), + return GetManager(managerHandle)->GetProjectedVolumeSubsetBufferSize((Voxel &) *minVoxelArray.data(), (Voxel &) *maxVoxelArray.data(), (DimensionsND) projectedDimensions, (VolumeDataChannelDescriptor::Format) format, @@ -255,12 +247,11 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGet * Signature: (JLjava/nio/FloatBuffer;JIII[I[IFFFFIII)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpRequestProjectedVolumeSubset - (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong layoutHandle, + (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong sampleBufferSize, jint jDimensionsND, jint lod, jint channel, jintArray minVoxelCoordinates, jintArray maxVoxelCoordinates, jfloat jVp0, jfloat jVp1, jfloat jVp2, jfloat jVp3, jint projectedDimensions, jint jFormat, jint interpolationMethod){ try { - VolumeDataAccessManager *manager = GetManager(managerHandle); - VolumeDataLayout *layout = GetLayout(layoutHandle); + IVolumeDataAccessManager *manager = GetManager(managerHandle); std::vector minVoxelArray = JArrayToVector(env, minVoxelCoordinates); std::vector maxVoxelArray = JArrayToVector(env, maxVoxelCoordinates); Voxel &minVoxel = (Voxel &) *minVoxelArray.data(); @@ -270,7 +261,7 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq FloatVector4 voxelPlane(jVp0, jVp1, jVp2, jVp3); auto output = static_cast(env->GetDirectBufferAddress(jsampleBuffer)); return manager->RequestProjectedVolumeSubset( - output, layout, dimensionsND, lod, channel, + output, sampleBufferSize, dimensionsND, lod, channel, minVoxel, maxVoxel, voxelPlane, (DimensionsND) projectedDimensions, format, (InterpolationMethod) interpolationMethod); } @@ -284,12 +275,11 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq * Signature: (JJJJIII[I[I[FIIIF)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpRequestProjectedVolumeSubsetR - (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong layoutHandle, + (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong sampleBufferSize, jint jDimensionsND, jint lod, jint channel, jintArray minVoxelCoordinates, jintArray maxVoxelCoordinates, jfloat jVp0, jfloat jVp1, jfloat jVp2, jfloat jVp3, jint projectedDimensions, jint jFormat, jint interpolationMethod, jfloat replacementNoValue) { try { - VolumeDataAccessManager *manager = GetManager(managerHandle); - VolumeDataLayout *layout = GetLayout(layoutHandle); + IVolumeDataAccessManager *manager = GetManager(managerHandle); std::vector minVoxelArray = JArrayToVector(env, minVoxelCoordinates); std::vector maxVoxelArray = JArrayToVector(env, maxVoxelCoordinates); Voxel &minVoxel = (Voxel &) *minVoxelArray.data(); @@ -299,7 +289,7 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq FloatVector4 voxelPlane(jVp0, jVp1, jVp2, jVp3); auto output = static_cast(env->GetDirectBufferAddress(jsampleBuffer)); return manager->RequestProjectedVolumeSubset( - output, layout, dimensionsND, lod, channel, + output, sampleBufferSize, dimensionsND, lod, channel, minVoxel, maxVoxel, voxelPlane, (DimensionsND) projectedDimensions, format, (InterpolationMethod) interpolationMethod, replacementNoValue); @@ -314,13 +304,12 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq * Signature: (JLjava/nio/FloatBuffer;JIIILjava/nio/FloatBuffer;II)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpRequestVolumeSamples - (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong layoutHandle, jint dimensionsND, + (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong sampleBufferSize, jint dimensionsND, jint lod, jint channel, jobject jpositionBuffer, jint sampleCount, jint interpolationMethod) { auto positions = reinterpret_cast(env->GetDirectBufferAddress(jpositionBuffer)); auto output = static_cast(env->GetDirectBufferAddress(jsampleBuffer)); try { - return GetManager(managerHandle)->RequestVolumeSamples(output, - GetLayout(layoutHandle), + return GetManager(managerHandle)->RequestVolumeSamples(output, sampleBufferSize, (DimensionsND) dimensionsND, lod, channel, positions, sampleCount, (InterpolationMethod) interpolationMethod); @@ -332,12 +321,12 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq /* * Class: org_opengroup_openvds_VolumeDataAccessManager * Method: cpGetVolumeSamplesBufferSize -* Signature: (JJII)J +* Signature: (JII)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGetVolumeSamplesBufferSize -(JNIEnv *env, jclass, jlong managerHandle, jlong layoutHandle, jint sampleCount, jint channel) { +(JNIEnv *env, jclass, jlong managerHandle, jint sampleCount, jint channel) { try { - return GetManager(managerHandle)->GetVolumeSamplesBufferSize(GetLayout(layoutHandle), sampleCount, channel); + return GetManager(managerHandle)->GetVolumeSamplesBufferSize(sampleCount, channel); } CATCH_EXCEPTIONS_FOR_JAVA; return 0; @@ -349,14 +338,13 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGet * Signature: (JLjava/nio/FloatBuffer;JIIILjava/nio/FloatBuffer;IIF)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpRequestVolumeSamplesR - (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong layoutHandle, jint dimensionsND, + (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong sampleBufferSize, jint dimensionsND, jint lod, jint channel, jobject jpositionBuffer, jint sampleCount, jint interpolationMethod, jfloat replacementValue) { auto positions = reinterpret_cast(env->GetDirectBufferAddress(jpositionBuffer)); auto output = static_cast(env->GetDirectBufferAddress(jsampleBuffer)); try { - return GetManager(managerHandle)->RequestVolumeSamples(output, - GetLayout(layoutHandle), + return GetManager(managerHandle)->RequestVolumeSamples(output, sampleBufferSize, (DimensionsND) dimensionsND, lod, channel, positions, sampleCount, (InterpolationMethod) interpolationMethod, @@ -369,12 +357,12 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq /* * Class: org_opengroup_openvds_VolumeDataAccessManager * Method: cpGetVolumeTracesBufferSize -* Signature: (JJIIII)J +* Signature: (JIIII)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGetVolumeTracesBufferSize - (JNIEnv *env, jclass, jlong managerHandle, jlong layoutHandle, jint traceCount, jint traceDimension, jint lod, jint channel) { + (JNIEnv *env, jclass, jlong managerHandle, jint traceCount, jint traceDimension, jint lod, jint channel) { try { - return GetManager(managerHandle)->GetVolumeTracesBufferSize(GetLayout(layoutHandle), traceCount, traceDimension, + return GetManager(managerHandle)->GetVolumeTracesBufferSize(traceCount, traceDimension, lod, channel); } CATCH_EXCEPTIONS_FOR_JAVA; @@ -387,16 +375,14 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpGet * Signature: (JLjava/nio/FloatBuffer;JIIILjava/nio/FloatBuffer;III)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpRequestVolumeTraces__JLjava_nio_FloatBuffer_2JIIILjava_nio_FloatBuffer_2III - (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong layoutHandle, + (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong sampleBufferSize, jint jDimensionsND, jint lod, jint channel, jobject jTracePositions, jint traceCount, jint interpolationMethod, jint traceDimension){ auto tracePositions = reinterpret_cast(env->GetDirectBufferAddress(jTracePositions)); auto output = static_cast(env->GetDirectBufferAddress(jsampleBuffer)); auto pManager = GetManager(managerHandle); - auto layout = GetLayout(layoutHandle); try { - return pManager->RequestVolumeTraces(output, - layout, + return pManager->RequestVolumeTraces(output, sampleBufferSize, (DimensionsND) jDimensionsND, lod, channel, tracePositions, traceCount, (InterpolationMethod) interpolationMethod, @@ -412,16 +398,14 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq * Signature: (JLjava/nio/FloatBuffer;JIIILjava/nio/FloatBuffer;IIIF)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpRequestVolumeTraces__JLjava_nio_FloatBuffer_2JIIILjava_nio_FloatBuffer_2IIIF - (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong layoutHandle, + (JNIEnv *env, jclass, jlong managerHandle, jobject jsampleBuffer, jlong sampleBufferSize, jint jDimensionsND, jint lod, jint channel, jobject jTracePositions, jint traceCount, jint interpolationMethod, jint traceDimension, jfloat replacementNoValue){ auto tracePositions = reinterpret_cast(env->GetDirectBufferAddress(jTracePositions)); auto output = static_cast(env->GetDirectBufferAddress(jsampleBuffer)); auto pManager = GetManager(managerHandle); - auto layout = GetLayout(layoutHandle); try { - return pManager->RequestVolumeTraces(output, - layout, + return pManager->RequestVolumeTraces(output, sampleBufferSize, (DimensionsND) jDimensionsND, lod, channel, tracePositions, traceCount, (InterpolationMethod) interpolationMethod, @@ -434,13 +418,13 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpReq /* * Class: org_opengroup_openvds_VolumeDataAccessManager * Method: cpPrefetchVolumeChunk -* Signature: (JJIIIJ)J +* Signature: (JIIIJ)J */ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_VolumeDataAccessManager_cpPrefetchVolumeChunk - (JNIEnv *env, jclass, jlong managerHandle, jlong layoutHandle, jint dimensionsND, jint lod, jint channel, + (JNIEnv *env, jclass, jlong managerHandle, jint dimensionsND, jint lod, jint channel, jlong chunk) { try { - return GetManager(managerHandle)->PrefetchVolumeChunk(GetLayout(layoutHandle), (DimensionsND) dimensionsND, lod, + return GetManager(managerHandle)->PrefetchVolumeChunk((DimensionsND) dimensionsND, lod, channel, chunk); } CATCH_EXCEPTIONS_FOR_JAVA; diff --git a/java/cpp/src/WriteVolumeData.cpp b/java/cpp/src/WriteVolumeData.cpp index 2e62295f..c14d744c 100644 --- a/java/cpp/src/WriteVolumeData.cpp +++ b/java/cpp/src/WriteVolumeData.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -50,7 +51,7 @@ template static void copy_data_to_chunk_2d(OpenVDS::VolumeDataPageAccessor *p_access, const T_src *src, const OpenVDS::VolumeDataLayout *layout, int chunk) { - const T_dst no_value = p_access->GetChannelDescriptor().GetNoValue(); + const T_dst no_value = OpenVDS::ConvertNoValue(p_access->GetChannelDescriptor().GetNoValue()); int min[OpenVDS::Dimensionality_Max]; int max[OpenVDS::Dimensionality_Max]; @@ -70,8 +71,7 @@ static void copy_data_to_chunk_2d(OpenVDS::VolumeDataPageAccessor *p_access, con for (int i = 0; i < chunk_size_z; i++) { std::ptrdiff_t i_src = size_z * (j + chunk_offset_x) + i + chunk_offset_z; std::ptrdiff_t i_dest = chunk_pitch[1] * j + i; - T_src val = check_isfinite((double) src[i_src]) ? src[i_src] : no_value; - dest[i_dest] = static_cast(val); + dest[i_dest] = check_isfinite((double) src[i_src]) ? static_cast(src[i_src]) : no_value; } } @@ -82,7 +82,7 @@ template static void copy_data_to_chunk_3d(OpenVDS::VolumeDataPageAccessor *p_access, const T_src *src, const OpenVDS::VolumeDataLayout *layout, int chunk) { - const T_dst no_value = p_access->GetChannelDescriptor().GetNoValue(); + const T_dst no_value = OpenVDS::ConvertNoValue(p_access->GetChannelDescriptor().GetNoValue()); int min[OpenVDS::Dimensionality_Max]; int max[OpenVDS::Dimensionality_Max]; @@ -106,8 +106,7 @@ static void copy_data_to_chunk_3d(OpenVDS::VolumeDataPageAccessor *p_access, con for (int i = 0; i < chunk_size_z; i++) { std::ptrdiff_t i_src = chunk_offset_z + i + size_z * (chunk_offset_x + j) + size_z * size_x * (chunk_offset_i + k); std::ptrdiff_t i_dest = chunk_pitch[2] * k + chunk_pitch[1] * j + i; - T_src val = check_isfinite((double) src[i_src]) ? src[i_src] : no_value; - dest[i_dest] = static_cast(val); + dest[i_dest] = check_isfinite((double) src[i_src]) ? static_cast(src[i_src]) : no_value; } } } @@ -177,8 +176,8 @@ static copy_fcn_t getCopyFunction_3d(OpenVDS::VolumeDataChannelDescriptor::Fo template void copy_data(const VDSHandle handle, const T *src, const std::string& channelName) { - auto *accessManager = OpenVDS::GetAccessManager(handle); - const auto *layout = accessManager->GetVolumeDataLayout(); + auto accessManager = OpenVDS::GetAccessManager(handle); + const auto *layout = accessManager.GetVolumeDataLayout(); const int lod_level = 0; const int max_pages = 8; @@ -200,9 +199,8 @@ void copy_data(const VDSHandle handle, const T *src, const std::string& channelN throw std::domain_error("Only 2D or 3D data can be written"); } - auto pageAccessor = accessManager->CreateVolumeDataPageAccessor(layout, - dim, lod_level, channel, max_pages, - OpenVDS::VolumeDataAccessManager::AccessMode_Create); + auto pageAccessor = accessManager.CreateVolumeDataPageAccessor(dim, lod_level, channel, max_pages, + OpenVDS::VolumeDataAccessManager::AccessMode_Create); for (int chunk = 0; chunk < pageAccessor->GetChunkCount(); chunk++) { copy_fcn(pageAccessor, src, layout, chunk); diff --git a/java/java/demo/AWSSliceDumpDemo.java b/java/java/demo/AWSSliceDumpDemo.java index dcce8d6a..2facfb29 100644 --- a/java/java/demo/AWSSliceDumpDemo.java +++ b/java/java/demo/AWSSliceDumpDemo.java @@ -96,7 +96,7 @@ public class AWSSliceDumpDemo { System.out.println("Request samples from VolumeDataAccessManager..."); FloatBuffer samplePositions = BufferUtils.toBuffer(samples); - long request = accessManager.requestVolumeSamples(data, layout, DimensionsND.DIMENSIONS_012, 0, 0, + long request = accessManager.requestVolumeSamples(data, DimensionsND.DIMENSIONS_012, 0, 0, samplePositions, elemCount, InterpolationMethod.LINEAR, 0); System.out.println("Wait for request completion..."); diff --git a/java/java/demo/OpenVdsDemo.java b/java/java/demo/OpenVdsDemo.java index d4da2b83..fbd0a6bc 100644 --- a/java/java/demo/OpenVdsDemo.java +++ b/java/java/demo/OpenVdsDemo.java @@ -84,7 +84,7 @@ public class OpenVdsDemo { final FloatBuffer data = BufferUtils.createFloatBuffer(output_width * output_height); System.out.println("Request samples from VolumeDataAccessManager..."); - long request = accessManager.requestVolumeSamples(data, layout, DimensionsND.DIMENSIONS_012, 0, 0, + long request = accessManager.requestVolumeSamples(data, DimensionsND.DIMENSIONS_012, 0, 0, BufferUtils.toBuffer(samples), elemCount, InterpolationMethod.LINEAR, 0); System.out.println("Wait for request completion..."); diff --git a/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java b/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java index 255daf1c..5be7cf2e 100644 --- a/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java +++ b/java/java/src/org/opengroup/openvds/VolumeDataAccessManager.java @@ -18,8 +18,6 @@ package org.opengroup.openvds; import java.nio.*; -import java.util.Arrays; -import java.util.Optional; import static org.opengroup.openvds.VolumeDataChannelDescriptor.Format.*; @@ -28,32 +26,6 @@ import static org.opengroup.openvds.VolumeDataChannelDescriptor.Format.*; */ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { - public enum AccessMode { - ReadOnly(0), - ReadWrite(1), - Create(2); - - private final int code; - - AccessMode(int code) { - this.code = code; - } - - public int getCode() { - return code; - } - - public static AccessMode fromCode(int codeParam) { - Optional first = Arrays - .stream(values()) - .filter(e -> e.getCode() == codeParam) - .findFirst(); - if (!first.isPresent()) - throw new IllegalArgumentException("invalid code"); - return first.get(); - } - } - private static native long cpGetVolumeDataLayout(long handle); private static native int cpGetVDSProduceStatus(long managerHandle, @@ -142,8 +114,6 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { private static native int cpUploadErrorCount(long handle); - private static native int cpGetCurrentUploadErrorCode(long handle); - public VolumeDataAccessManager(long handle) { super(handle); } @@ -159,7 +129,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @return the VolumeDataLayout object associated with the VDS or null if * there is no valid VolumeDataLayout. */ - public VolumeDataLayout getVolumeDataLayout() { + VolumeDataLayout getVolumeDataLayout() { return new VolumeDataLayout(cpGetVolumeDataLayout(_handle)); } @@ -176,7 +146,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @return The produce status for the specific DimensionsND/LOD/Channel * combination. */ - public VDSProduceStatus getVDSProduceStatus(VolumeDataLayout volumeDataLayout, DimensionsND dimensionsND, int lod, int channel) { + VDSProduceStatus getVDSProduceStatus(VolumeDataLayout volumeDataLayout, DimensionsND dimensionsND, int lod, int channel) { return VDSProduceStatus.values()[cpGetVDSProduceStatus(_handle, volumeDataLayout.handle(), dimensionsND.ordinal(), lod, channel)]; } @@ -198,7 +168,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @return a VolumeDataPageAccessor object for the VDS associated with the * given VolumeDataLayout object. */ - public VolumeDataPageAccessor createVolumeDataPageAccessor(VolumeDataLayout volumeDataLayout, + VolumeDataPageAccessor createVolumeDataPageAccessor(VolumeDataLayout volumeDataLayout, int dimensionsND, int lod, int channel, int maxPages, int accessMode) { return new VolumeDataPageAccessor(cpCreateVolumeDataPageAccessor( _handle, volumeDataLayout.handle(), @@ -226,7 +196,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @return a VolumeDataPageAccessor object for the VDS associated with the * given VolumeDataLayout object. */ - public VolumeDataPageAccessor createVolumeDataPageAccessor(VolumeDataLayout volumeDataLayout, + VolumeDataPageAccessor createVolumeDataPageAccessor(VolumeDataLayout volumeDataLayout, int dimensionsND, int lod, int channel, int maxPages, int accessMode, int chunkMetadataPageSize) { return new VolumeDataPageAccessor(cpCreateVolumeDataPageAccessor( _handle, volumeDataLayout.handle(), @@ -239,7 +209,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @param volumeDataPageAccessor the VolumeDataPageAccessor object to * destroy. */ - public void destroyVolumeDataPageAccessor(VolumeDataPageAccessor volumeDataPageAccessor) { + void destroyVolumeDataPageAccessor(VolumeDataPageAccessor volumeDataPageAccessor) { cpDestroyVolumeDataPageAccessor(_handle, volumeDataPageAccessor.handle()); } @@ -248,7 +218,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * * @param accessor the VolumeDataAccessor object to destroy. */ - public void destroyVolumeDataAccessor(VolumeDataAccessor accessor) { + void destroyVolumeDataAccessor(VolumeDataAccessor accessor) { cpDestroyVolumeDataAccessor(_handle, accessor.handle()); } @@ -258,7 +228,7 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { * @param accessor the VolumeDataAccessor object to clone. * @return a clone of supplied VolumeDataAccessor object */ - public VolumeDataAccessor cloneVolumeDataAccessor(VolumeDataAccessor accessor) { + VolumeDataAccessor cloneVolumeDataAccessor(VolumeDataAccessor accessor) { return new VolumeDataAccessor(cpCloneVolumeDataAccessor(_handle, accessor.handle()), true); } @@ -302,7 +272,6 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { volumeDataLayout.handle(), dimensionsND.ordinal(), lod, channel, box.getMin(), box.getMax(), FORMAT_R64.getCode()); } - public long requestVolumeSubset(FloatBuffer outBuf, VolumeDataLayout volumeDataLayout, DimensionsND dimensionsND, int lod, int channel, NDBox box) { @@ -793,8 +762,4 @@ public class VolumeDataAccessManager extends JniPointerWithoutDeletion { public int uploadErrorCount() { return cpUploadErrorCount(_handle); } - - public int getCurrentUploadErrorCode() { - return cpGetCurrentUploadErrorCode(_handle); - } } diff --git a/java/java/test/org/opengroup/openvds/AmazonS3Test.java b/java/java/test/org/opengroup/openvds/AmazonS3Test.java index bc09f24b..96feb162 100644 --- a/java/java/test/org/opengroup/openvds/AmazonS3Test.java +++ b/java/java/test/org/opengroup/openvds/AmazonS3Test.java @@ -73,15 +73,15 @@ public class AmazonS3Test { final FloatBuffer floatBuffer0 = BufferUtils.createFloatBuffer(nZSamples * nYSamples); final VolumeDataAccessManager accessManager = openVDS.getAccessManager(); assertTrue(!accessManager.isNull()); - final long requestId1 = accessManager.requestVolumeSubset( - floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); - final long requestId0 = accessManager.requestVolumeSubset( - floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, box, layout.getChannelNoValue(0)); - - System.out.println("Wait for request completion " + requestId1 + " ..."); - waitAndDisplayProgress(accessManager, requestId1); - System.out.println("Wait for request completion " + requestId1 + " ..."); - waitAndDisplayProgress(accessManager, requestId0); + final long requestID1 = accessManager.requestVolumeSubset( + floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestID0 = accessManager.requestVolumeSubset( + floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box, layout.getChannelNoValue(0)); + + System.out.println("Wait for request completion " + requestID1 + " ..."); + waitAndDisplayProgress(accessManager, requestID1); + System.out.println("Wait for request completion " + requestID1 + " ..."); + waitAndDisplayProgress(accessManager, requestID0); for (int i = 0; i < nZSamples * nYSamples; i++) { final float f1 = floatBuffer0.get(i); diff --git a/java/java/test/org/opengroup/openvds/CreateVDSTest.java b/java/java/test/org/opengroup/openvds/CreateVDSTest.java index 3574c491..f37460cb 100644 --- a/java/java/test/org/opengroup/openvds/CreateVDSTest.java +++ b/java/java/test/org/opengroup/openvds/CreateVDSTest.java @@ -34,7 +34,7 @@ public class CreateVDSTest { for (VolumeDataLayoutDescriptor.LODLevels l : VolumeDataLayoutDescriptor.LODLevels.values()) { for (int channel = 0; channel < nbChannel; channel++) { for (DimensionsND dimGroup : DimensionsND.values()) { - VDSProduceStatus vdsProduceStatus = accessManager.getVDSProduceStatus(volumeDataLayout, dimGroup, l.ordinal(), channel); + VDSProduceStatus vdsProduceStatus = accessManager.getVDSProduceStatus(dimGroup, l.ordinal(), channel); } } } diff --git a/java/java/test/org/opengroup/openvds/MemoryVdsGeneratorTest.java b/java/java/test/org/opengroup/openvds/MemoryVdsGeneratorTest.java index 76addb9a..f90f63ba 100644 --- a/java/java/test/org/opengroup/openvds/MemoryVdsGeneratorTest.java +++ b/java/java/test/org/opengroup/openvds/MemoryVdsGeneratorTest.java @@ -89,15 +89,15 @@ public class MemoryVdsGeneratorTest { } final FloatBuffer floatBuffer1 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId = accessManager.requestVolumeTraces(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestSubsetId = accessManager.requestVolumeTraces(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, tracePositions, nYSamples, InterpolationMethod.NEAREST, 0); accessManager.waitForCompletion(requestSubsetId); final FloatBuffer floatBuffer0 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestId0 = accessManager.requestVolumeSamples( - floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID0 = accessManager.requestVolumeSamples( + floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, samplePositions, nZSamples * nYSamples, InterpolationMethod.NEAREST); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID0); B.release(samplePositions, tracePositions); @@ -127,7 +127,7 @@ public class MemoryVdsGeneratorTest { final VolumeDataAccessManager accessManager = generator.getAccessManager(); assertTrue(!accessManager.isNull()); - final long volumeTracesBufferSize = accessManager.getVolumeTracesBufferSize(layout, nYSamples, 0, 0, 0); + final long volumeTracesBufferSize = accessManager.getVolumeTracesBufferSize(nYSamples, 0, 0, 0); assertEquals(nZSamples * nYSamples * Float.BYTES, volumeTracesBufferSize); final FloatBuffer tracePositions = B.createFloatBuffer(nYSamples * VolumeDataAccessManager.Dimensionality_Max); @@ -141,14 +141,14 @@ public class MemoryVdsGeneratorTest { } final FloatBuffer floatBuffer1 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId = accessManager.requestVolumeTraces(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestSubsetId = accessManager.requestVolumeTraces(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, tracePositions, nYSamples, InterpolationMethod.NEAREST, 0); accessManager.waitForCompletion(requestSubsetId); final FloatBuffer floatBuffer0 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestId0 = accessManager.requestVolumeTraces(floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID0 = accessManager.requestVolumeTraces(floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, tracePositions, nYSamples, InterpolationMethod.NEAREST, 0, layout.getChannelNoValue(0)); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID0); B.release(tracePositions); @@ -181,11 +181,11 @@ public class MemoryVdsGeneratorTest { NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, 1, 0, 0, 0); final FloatBuffer floatBuffer1 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId1 = accessManager.requestVolumeSubset(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestSubsetId1 = accessManager.requestVolumeSubset(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); accessManager.waitForCompletion(requestSubsetId1); final FloatBuffer floatBuffer0 = B.toBuffer(new float[nZSamples * nYSamples]); - final long requestSubsetId0 = accessManager.requestVolumeSubset(floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestSubsetId0 = accessManager.requestVolumeSubset(floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box); accessManager.waitForCompletion(requestSubsetId0); for (int i = 0; i < nZSamples * nYSamples; i++) { @@ -217,11 +217,11 @@ public class MemoryVdsGeneratorTest { NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, 1, 0, 0, 0); final FloatBuffer floatBuffer1 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId1 = accessManager.requestVolumeSubset(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestSubsetId1 = accessManager.requestVolumeSubset(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); accessManager.waitForCompletion(requestSubsetId1); final FloatBuffer floatBuffer0 = B.toBuffer(new float[nZSamples * nYSamples]); - final long requestSubsetId0 = accessManager.requestVolumeSubset(floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestSubsetId0 = accessManager.requestVolumeSubset(floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box); accessManager.waitForCompletion(requestSubsetId0); float[] floatArray = B.toArrayAndRelease(floatBuffer0); @@ -266,14 +266,14 @@ public class MemoryVdsGeneratorTest { NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, 1, 0, 0, 0); final FloatBuffer floatBuffer1 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId = accessManager.requestVolumeSubset(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestSubsetId = accessManager.requestVolumeSubset(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); accessManager.waitForCompletion(requestSubsetId); final FloatBuffer floatBuffer0 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestId0 = accessManager.requestVolumeSamples( - floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID0 = accessManager.requestVolumeSamples( + floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, samplePositions, nZSamples * nYSamples, InterpolationMethod.NEAREST); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID0); B.release(samplePositions); @@ -306,12 +306,12 @@ public class MemoryVdsGeneratorTest { NDBox wholeCube = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, nXSamples, 0, 0, 0); final FloatBuffer floatBuffer1 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId = accessManager.requestProjectedVolumeSubset(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestSubsetId = accessManager.requestProjectedVolumeSubset(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, wholeCube, 0.5f, 0.1f, 0.9f, 1.f, DimensionsND.DIMENSIONS_01, InterpolationMethod.NEAREST); accessManager.waitForCompletion(requestSubsetId); final FloatBuffer floatBuffer0 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId0 = accessManager.requestProjectedVolumeSubset(floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestSubsetId0 = accessManager.requestProjectedVolumeSubset(floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, wholeCube, 0.5f, 0.1f, 0.9f, 1.f, DimensionsND.DIMENSIONS_01, InterpolationMethod.NEAREST, layout.getChannelNoValue(0)); accessManager.waitForCompletion(requestSubsetId0); @@ -343,20 +343,20 @@ public class MemoryVdsGeneratorTest { NDBox wholeCube = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, nXSamples, 0, 0, 0); - final long projectedVolumeSubsetBufferSize = accessManager.getProjectedVolumeSubsetBufferSize(layout, wholeCube, DimensionsND.DIMENSIONS_01, FORMAT_R32, 0, 0); + final long projectedVolumeSubsetBufferSize = accessManager.getProjectedVolumeSubsetBufferSize(wholeCube, DimensionsND.DIMENSIONS_01, FORMAT_R32, 0, 0); assertEquals(nZSamples * nYSamples * Float.BYTES, projectedVolumeSubsetBufferSize); final FloatBuffer floatBuffer1 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId = accessManager.requestProjectedVolumeSubset(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestSubsetId = accessManager.requestProjectedVolumeSubset(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, wholeCube, 0.5f, 0.1f, 0.9f, 1.f, DimensionsND.DIMENSIONS_01, InterpolationMethod.NEAREST); accessManager.waitForCompletion(requestSubsetId); NDBox boxSlice = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, 1, 0, 0, 0); final FloatBuffer floatBuffer0 = B.createFloatBuffer(nZSamples * nYSamples); final float channelNoValue = layout.getChannelNoValue(0); - final long requestId0 = accessManager.requestVolumeSubset(floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID0 = accessManager.requestVolumeSubset(floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, boxSlice, channelNoValue); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID0); for (int i = 0; i < nZSamples * nYSamples; i++) { final float f1 = floatBuffer0.get(i); @@ -391,13 +391,13 @@ public class MemoryVdsGeneratorTest { final FloatBuffer floatBuffer0 = B.createFloatBuffer(nZSamples * nYSamples); final VolumeDataAccessManager accessManager = generator.getAccessManager(); assertTrue(!accessManager.isNull()); - final long requestId1 = accessManager.requestVolumeSubset( - floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); - final long requestId0 = accessManager.requestVolumeSubset( - floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, box, layout.getChannelNoValue(0)); + final long requestID1 = accessManager.requestVolumeSubset( + floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestID0 = accessManager.requestVolumeSubset( + floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box, layout.getChannelNoValue(0)); - accessManager.waitForCompletion(requestId1); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID1); + accessManager.waitForCompletion(requestID0); for (int i = 0; i < nZSamples * nYSamples; i++) { final float f1 = floatBuffer0.get(i); @@ -439,13 +439,13 @@ public class MemoryVdsGeneratorTest { final FloatBuffer floatBuffer0 = BufferUtils.createFloatBuffer(nZSamples * nYSamples); final VolumeDataAccessManager accessManager = generator.getAccessManager(); assertTrue(!accessManager.isNull()); - final long requestId1 = accessManager.requestVolumeSubset( - floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); - final long requestId0 = accessManager.requestVolumeSubset( - floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, box, layout.getChannelNoValue(0)); + final long requestID1 = accessManager.requestVolumeSubset( + floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestID0 = accessManager.requestVolumeSubset( + floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box, layout.getChannelNoValue(0)); - accessManager.waitForCompletion(requestId1); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID1); + accessManager.waitForCompletion(requestID0); for (int i = 0; i < nZSamples * nYSamples; i++) { final float f1 = floatBuffer0.get(i); @@ -509,13 +509,13 @@ public class MemoryVdsGeneratorTest { final VolumeDataAccessManager accessManager = generator.getAccessManager(); assertTrue(!accessManager.isNull()); // synchronized (accessManager) { - final long requestId1 = accessManager.requestVolumeSubset( - floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, box); - final long requestId0 = accessManager.requestVolumeSubset( - floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, box, layout.getChannelNoValue(0)); + final long requestID1 = accessManager.requestVolumeSubset( + floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); + final long requestID0 = accessManager.requestVolumeSubset( + floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box, layout.getChannelNoValue(0)); - waitComplationAndDisplayProgress(accessManager, requestId1); - waitComplationAndDisplayProgress(accessManager, requestId0); + waitComplationAndDisplayProgress(accessManager, requestID1); + waitComplationAndDisplayProgress(accessManager, requestID0); for (int i = 0; i < nZSamples * nYSamples; i++) { final float f1 = floatBuffer0.get(i); @@ -525,7 +525,7 @@ public class MemoryVdsGeneratorTest { B.release(floatBuffer0, floatBuffer1); -// System.out.println("Done " + requestId0 + " " + requestId1); +// System.out.println("Done " + requestID0 + " " + requestID1); // System.out.flush(); return null; })); @@ -571,15 +571,15 @@ public class MemoryVdsGeneratorTest { NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, 1, 0, 0, 0); final FloatBuffer floatBuffer1 = B.createFloatBuffer(nZSamples * nYSamples); - final long requestSubsetId = accessManager.requestVolumeSubset(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestSubsetId = accessManager.requestVolumeSubset(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); accessManager.waitForCompletion(requestSubsetId); final FloatBuffer floatBuffer0 = B.createFloatBuffer(nZSamples * nYSamples); final float channelNoValue = layout.getChannelNoValue(0); - final long requestId0 = accessManager.requestVolumeSubset(floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID0 = accessManager.requestVolumeSubset(floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box, channelNoValue); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID0); for (int i = 0; i < nZSamples * nYSamples; i++) { final float f1 = floatBuffer0.get(i); @@ -610,15 +610,15 @@ public class MemoryVdsGeneratorTest { NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, 1, 0, 0, 0); final ByteBuffer floatBuffer1 = B.createByteBuffer(nZSamples * nYSamples); - final long requestSubsetId = accessManager.requestVolumeSubset(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestSubsetId = accessManager.requestVolumeSubset(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); accessManager.waitForCompletion(requestSubsetId); final ByteBuffer floatBuffer0 = B.createByteBuffer(nZSamples * nYSamples); final float channelNoValue = layout.getChannelNoValue(0); - final long requestId0 = accessManager.requestVolumeSubset(floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID0 = accessManager.requestVolumeSubset(floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box, channelNoValue); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID0); for (int i = 0; i < nZSamples * nYSamples; i++) { final float f1 = floatBuffer0.get(i); @@ -649,15 +649,15 @@ public class MemoryVdsGeneratorTest { NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nZSamples, nYSamples, 1, 0, 0, 0); final IntBuffer floatBuffer1 = B.createIntBuffer(nZSamples * nYSamples); - final long requestSubsetId = accessManager.requestVolumeSubset(floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestSubsetId = accessManager.requestVolumeSubset(floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, box); accessManager.waitForCompletion(requestSubsetId); final IntBuffer floatBuffer0 = B.createIntBuffer(nZSamples * nYSamples); final float channelNoValue = layout.getChannelNoValue(0); - final long requestId0 = accessManager.requestVolumeSubset(floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID0 = accessManager.requestVolumeSubset(floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, box, channelNoValue); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID0); for (int i = 0; i < nZSamples * nYSamples; i++) { final float f1 = floatBuffer0.get(i); @@ -698,16 +698,16 @@ public class MemoryVdsGeneratorTest { } final FloatBuffer floatBuffer0 = BufferUtils.createFloatBuffer(NB_SAMPLE_REQUESTED); - final long requestId0 = accessManager.requestVolumeSamples( - floatBuffer0, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID0 = accessManager.requestVolumeSamples( + floatBuffer0, DimensionsND.DIMENSIONS_012, 0, 0, samplePositions, NB_SAMPLE_REQUESTED, InterpolationMethod.LINEAR); - accessManager.waitForCompletion(requestId0); + accessManager.waitForCompletion(requestID0); final FloatBuffer floatBuffer1 = BufferUtils.createFloatBuffer(NB_SAMPLE_REQUESTED); - final long requestId1 = accessManager.requestVolumeSamples( - floatBuffer1, layout, DimensionsND.DIMENSIONS_012, 0, 0, + final long requestID1 = accessManager.requestVolumeSamples( + floatBuffer1, DimensionsND.DIMENSIONS_012, 0, 0, samplePositions, NB_SAMPLE_REQUESTED, InterpolationMethod.LINEAR, Float.NaN); - accessManager.waitForCompletion(requestId1); + accessManager.waitForCompletion(requestID1); for (int i = 0; i < NB_SAMPLE_REQUESTED; i++) { final float f1 = floatBuffer0.get(i); @@ -731,7 +731,7 @@ public class MemoryVdsGeneratorTest { for (VolumeDataLayoutDescriptor.LODLevels l : VolumeDataLayoutDescriptor.LODLevels.values()) { for (int channel = 0; channel < nbChannel; channel++) { for (DimensionsND dimGroup : DimensionsND.values()) { - VDSProduceStatus vdsProduceStatus = accessManager.getVDSProduceStatus(layout, dimGroup, l.ordinal(), channel); + VDSProduceStatus vdsProduceStatus = accessManager.getVDSProduceStatus(dimGroup, l.ordinal(), channel); if (channel == 0 && LOD_LEVELS_NONE.equals(l) && DimensionsND.DIMENSIONS_012.equals(dimGroup)) assertEquals(VDSProduceStatus.NORMAL, vdsProduceStatus); else diff --git a/java/java/test/org/opengroup/openvds/WriteDataTest.java b/java/java/test/org/opengroup/openvds/WriteDataTest.java index d580e291..6070af34 100644 --- a/java/java/test/org/opengroup/openvds/WriteDataTest.java +++ b/java/java/test/org/opengroup/openvds/WriteDataTest.java @@ -63,15 +63,16 @@ public class WriteDataTest { VolumeDataAccessManager access = vds2.getAccessManager(); VolumeDataLayout layout = vds2.getLayout(); + NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nz, nx, 0, 0, 0, 0); int channel = layout.getChannelIndex("chan1"); - long size = access.getVolumeSubsetBufferSize(layout, box, f, 0, channel); + long size = access.getVolumeSubsetBufferSize(box, f, 0, channel); java.nio.FloatBuffer outbuf = BufferUtils.createFloatBuffer((int) size / 4); DimensionsND dims = DimensionsND.DIMENSIONS_01; - long t = access.requestVolumeSubset(outbuf, layout, dims, 0, channel, box); + long t = access.requestVolumeSubset(outbuf, dims, 0, channel, box); access.waitForCompletion(t); float[] arr = new float[outbuf.remaining()]; outbuf.get(arr); @@ -128,11 +129,12 @@ public class WriteDataTest { NDBox box = new NDBox(0, 0, 0, 0, 0, 0, nz, ny, nx, 0, 0, 0); int channel = layout.getChannelIndex("chan2"); - long size = access.getVolumeSubsetBufferSize(layout, box, f, 0, channel); + long size = access.getVolumeSubsetBufferSize(box, f, 0, channel); + java.nio.FloatBuffer outbuf = BufferUtils.createFloatBuffer((int) size / 4); DimensionsND dims = DimensionsND.DIMENSIONS_012; - long t = access.requestVolumeSubset(outbuf, layout, dims, 0, channel, box); + long t = access.requestVolumeSubset(outbuf, dims, 0, channel, box); access.waitForCompletion(t); float[] arr = new float[outbuf.remaining()]; outbuf.get(arr); diff --git a/python/openvds/CMakeLists.txt b/python/openvds/CMakeLists.txt index 869369f0..9935a475 100644 --- a/python/openvds/CMakeLists.txt +++ b/python/openvds/CMakeLists.txt @@ -19,6 +19,8 @@ pybind11_add_module(core MODULE SYSTEM PyVolumeData.h PyVolumeDataAccess.cpp PyVolumeDataAccess.h + PyVolumeDataAccessManager.cpp + PyVolumeDataAccessManager.h PyVolumeDataAxisDescriptor.cpp PyVolumeDataAxisDescriptor.h PyVolumeDataChannelDescriptor.cpp diff --git a/python/openvds/PyGlobal.cpp b/python/openvds/PyGlobal.cpp index 68d9d3f5..1a511c74 100644 --- a/python/openvds/PyGlobal.cpp +++ b/python/openvds/PyGlobal.cpp @@ -233,7 +233,8 @@ PyGlobal::initModule(py::module& m) m.def("create" , static_cast, VectorWrapper, const native::MetadataReadAccess &, native::Error &)>(&Create), py::arg("options").none(false), py::arg("layoutDescriptor").none(false), py::arg("axisDescriptors").none(false), py::arg("channelDescriptors").none(false), py::arg("metadata").none(false), py::arg("error").none(false), OPENVDS_DOCSTRING(Create_3)); m.def("create" , static_cast, VectorWrapper, const native::MetadataReadAccess &, native::Error &)>(&Create), py::arg("ioManager").none(false), py::arg("layoutDescriptor").none(false), py::arg("axisDescriptors").none(false), py::arg("channelDescriptors").none(false), py::arg("metadata").none(false), py::arg("error").none(false), OPENVDS_DOCSTRING(Create_4)); m.def("getLayout" , static_cast(&GetLayout), py::arg("handle").none(false), OPENVDS_DOCSTRING(GetLayout)); - m.def("getAccessManager" , static_cast(&GetAccessManager), py::arg("handle").none(false), OPENVDS_DOCSTRING(GetAccessManager)); + m.def("getAccessManagerInterface" , static_cast(&GetAccessManagerInterface), py::arg("handle").none(false), OPENVDS_DOCSTRING(GetAccessManagerInterface)); + m.def("getAccessManager" , static_cast(&GetAccessManager), py::arg("handle").none(false), OPENVDS_DOCSTRING(GetAccessManager)); m.def("close" , static_cast(&Close), py::arg("handle").none(false), OPENVDS_DOCSTRING(Close)); m.def("getGlobalState" , static_cast(&GetGlobalState), OPENVDS_DOCSTRING(GetGlobalState)); //AUTOGEN-END diff --git a/python/openvds/PyVolumeDataAccess.cpp b/python/openvds/PyVolumeDataAccess.cpp index d09a845c..a1bcc386 100644 --- a/python/openvds/PyVolumeDataAccess.cpp +++ b/python/openvds/PyVolumeDataAccess.cpp @@ -114,89 +114,32 @@ PyVolumeDataAccess::initModule(py::module& m) VDSProduceStatus_.value("Remapped" , VDSProduceStatus::Remapped , OPENVDS_DOCSTRING(VDSProduceStatus_Remapped)); VDSProduceStatus_.value("Unavailable" , VDSProduceStatus::Unavailable , OPENVDS_DOCSTRING(VDSProduceStatus_Unavailable)); - // VolumeDataAccessor - py::class_> - VolumeDataAccessor_(m,"VolumeDataAccessor", OPENVDS_DOCSTRING(VolumeDataAccessor)); - - VolumeDataAccessor_.def("getManager" , static_cast(&VolumeDataAccessor::GetManager), OPENVDS_DOCSTRING(VolumeDataAccessor_GetManager)); - VolumeDataAccessor_.def_property_readonly("manager", &VolumeDataAccessor::GetManager, OPENVDS_DOCSTRING(VolumeDataAccessor_GetManager)); - VolumeDataAccessor_.def("getLayout" , static_cast(&VolumeDataAccessor::GetLayout), OPENVDS_DOCSTRING(VolumeDataAccessor_GetLayout)); - VolumeDataAccessor_.def_property_readonly("layout", &VolumeDataAccessor::GetLayout, OPENVDS_DOCSTRING(VolumeDataAccessor_GetLayout)); - VolumeDataAccessor_.def("getBase" , static_cast(&VolumeDataAccessor::GetBase), OPENVDS_DOCSTRING(VolumeDataAccessor_GetBase)); - VolumeDataAccessor_.def_property_readonly("base", &VolumeDataAccessor::GetBase, OPENVDS_DOCSTRING(VolumeDataAccessor_GetBase)); - - // VolumeDataAccessor::IndexOutOfRangeException - py::class_> - VolumeDataAccessor_IndexOutOfRangeException_(VolumeDataAccessor_,"VolumeDataAccessor::IndexOutOfRangeException", OPENVDS_DOCSTRING(VolumeDataAccessor_IndexOutOfRangeException)); - - // VolumeDataAccessManager - py::class_> - VolumeDataAccessManager_(m,"VolumeDataAccessManager", OPENVDS_DOCSTRING(VolumeDataAccessManager)); - - VolumeDataAccessManager_.def("getVolumeDataLayout" , static_cast(&VolumeDataAccessManager::GetVolumeDataLayout), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVolumeDataLayout)); - VolumeDataAccessManager_.def_property_readonly("volumeDataLayout", &VolumeDataAccessManager::GetVolumeDataLayout, OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVolumeDataLayout)); - VolumeDataAccessManager_.def("getVDSProduceStatus" , static_cast(&VolumeDataAccessManager::GetVDSProduceStatus), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVDSProduceStatus)); - VolumeDataAccessManager_.def("destroyVolumeDataPageAccessor", static_cast(&VolumeDataAccessManager::DestroyVolumeDataPageAccessor), py::arg("volumeDataPageAccessor").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_DestroyVolumeDataPageAccessor)); - VolumeDataAccessManager_.def("destroyVolumeDataAccessor" , static_cast(&VolumeDataAccessManager::DestroyVolumeDataAccessor), py::arg("accessor").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_DestroyVolumeDataAccessor)); - VolumeDataAccessManager_.def("cloneVolumeDataAccessor" , static_cast(&VolumeDataAccessManager::CloneVolumeDataAccessor), py::arg("accessor").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_CloneVolumeDataAccessor)); - VolumeDataAccessManager_.def("create2DVolumeDataAccessor1Bit", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create2DVolumeDataAccessor1Bit), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DVolumeDataAccessor1Bit)); - VolumeDataAccessManager_.def("create2DVolumeDataAccessorU8", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create2DVolumeDataAccessorU8), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DVolumeDataAccessorU8)); - VolumeDataAccessManager_.def("create2DVolumeDataAccessorU16", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create2DVolumeDataAccessorU16), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DVolumeDataAccessorU16)); - VolumeDataAccessManager_.def("create2DVolumeDataAccessorU32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create2DVolumeDataAccessorU32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DVolumeDataAccessorU32)); - VolumeDataAccessManager_.def("create2DVolumeDataAccessorU64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create2DVolumeDataAccessorU64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DVolumeDataAccessorU64)); - VolumeDataAccessManager_.def("create2DVolumeDataAccessorR32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create2DVolumeDataAccessorR32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DVolumeDataAccessorR32)); - VolumeDataAccessManager_.def("create2DVolumeDataAccessorR64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create2DVolumeDataAccessorR64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DVolumeDataAccessorR64)); - VolumeDataAccessManager_.def("create3DVolumeDataAccessor1Bit", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create3DVolumeDataAccessor1Bit), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DVolumeDataAccessor1Bit)); - VolumeDataAccessManager_.def("create3DVolumeDataAccessorU8", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create3DVolumeDataAccessorU8), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DVolumeDataAccessorU8)); - VolumeDataAccessManager_.def("create3DVolumeDataAccessorU16", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create3DVolumeDataAccessorU16), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DVolumeDataAccessorU16)); - VolumeDataAccessManager_.def("create3DVolumeDataAccessorU32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create3DVolumeDataAccessorU32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DVolumeDataAccessorU32)); - VolumeDataAccessManager_.def("create3DVolumeDataAccessorU64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create3DVolumeDataAccessorU64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DVolumeDataAccessorU64)); - VolumeDataAccessManager_.def("create3DVolumeDataAccessorR32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create3DVolumeDataAccessorR32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DVolumeDataAccessorR32)); - VolumeDataAccessManager_.def("create3DVolumeDataAccessorR64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create3DVolumeDataAccessorR64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DVolumeDataAccessorR64)); - VolumeDataAccessManager_.def("create4DVolumeDataAccessor1Bit", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create4DVolumeDataAccessor1Bit), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DVolumeDataAccessor1Bit)); - VolumeDataAccessManager_.def("create4DVolumeDataAccessorU8", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create4DVolumeDataAccessorU8), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DVolumeDataAccessorU8)); - VolumeDataAccessManager_.def("create4DVolumeDataAccessorU16", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create4DVolumeDataAccessorU16), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DVolumeDataAccessorU16)); - VolumeDataAccessManager_.def("create4DVolumeDataAccessorU32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create4DVolumeDataAccessorU32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DVolumeDataAccessorU32)); - VolumeDataAccessManager_.def("create4DVolumeDataAccessorU64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create4DVolumeDataAccessorU64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DVolumeDataAccessorU64)); - VolumeDataAccessManager_.def("create4DVolumeDataAccessorR32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create4DVolumeDataAccessorR32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DVolumeDataAccessorR32)); - VolumeDataAccessManager_.def("create4DVolumeDataAccessorR64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float)>(&VolumeDataAccessManager::Create4DVolumeDataAccessorR64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DVolumeDataAccessorR64)); - VolumeDataAccessManager_.def("create2DInterpolatingVolumeDataAccessorR32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float, native::InterpolationMethod)>(&VolumeDataAccessManager::Create2DInterpolatingVolumeDataAccessorR32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DInterpolatingVolumeDataAccessorR32)); - VolumeDataAccessManager_.def("create2DInterpolatingVolumeDataAccessorR64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float, native::InterpolationMethod)>(&VolumeDataAccessManager::Create2DInterpolatingVolumeDataAccessorR64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create2DInterpolatingVolumeDataAccessorR64)); - VolumeDataAccessManager_.def("create3DInterpolatingVolumeDataAccessorR32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float, native::InterpolationMethod)>(&VolumeDataAccessManager::Create3DInterpolatingVolumeDataAccessorR32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DInterpolatingVolumeDataAccessorR32)); - VolumeDataAccessManager_.def("create3DInterpolatingVolumeDataAccessorR64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float, native::InterpolationMethod)>(&VolumeDataAccessManager::Create3DInterpolatingVolumeDataAccessorR64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create3DInterpolatingVolumeDataAccessorR64)); - VolumeDataAccessManager_.def("create4DInterpolatingVolumeDataAccessorR32", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float, native::InterpolationMethod)>(&VolumeDataAccessManager::Create4DInterpolatingVolumeDataAccessorR32), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DInterpolatingVolumeDataAccessorR32)); - VolumeDataAccessManager_.def("create4DInterpolatingVolumeDataAccessorR64", static_cast *(VolumeDataAccessManager::*)(native::VolumeDataPageAccessor *, float, native::InterpolationMethod)>(&VolumeDataAccessManager::Create4DInterpolatingVolumeDataAccessorR64), py::arg("volumeDataPageAccessor").none(false), py::arg("replacementNoValue").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Create4DInterpolatingVolumeDataAccessorR64)); - VolumeDataAccessManager_.def("getVolumeSubsetBufferSize" , [](VolumeDataAccessManager* self, const OpenVDS::VolumeDataLayout * volumeDataLayout, const py::array_t& minVoxelCoordinates, const py::array_t& maxVoxelCoordinates, VolumeDataChannelDescriptor::Format format, int lod, int channel) { return self->GetVolumeSubsetBufferSize(volumeDataLayout, PyArrayAdapter::getArrayChecked(minVoxelCoordinates), PyArrayAdapter::getArrayChecked(maxVoxelCoordinates), format, lod, channel); }, py::arg("volumeDataLayout"), py::arg("minVoxelCoordinates"), py::arg("maxVoxelCoordinates"), py::arg("format"), py::arg("lod"), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVolumeSubsetBufferSize)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("requestVolumeSubset" , static_cast(&VolumeDataAccessManager::RequestVolumeSubset), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("format").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSubset)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("requestVolumeSubset" , static_cast(&VolumeDataAccessManager::RequestVolumeSubset), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lOD").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("format").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSubset_2)); - VolumeDataAccessManager_.def("getProjectedVolumeSubsetBufferSize", [](VolumeDataAccessManager* self, const OpenVDS::VolumeDataLayout * volumeDataLayout, const py::array_t& minVoxelCoordinates, const py::array_t& maxVoxelCoordinates, OpenVDS::DimensionsND projectedDimensions, VolumeDataChannelDescriptor::Format format, int lod, int channel) { return self->GetProjectedVolumeSubsetBufferSize(volumeDataLayout, PyArrayAdapter::getArrayChecked(minVoxelCoordinates), PyArrayAdapter::getArrayChecked(maxVoxelCoordinates), projectedDimensions, format, lod, channel); }, py::arg("volumeDataLayout"), py::arg("minVoxelCoordinates"), py::arg("maxVoxelCoordinates"), py::arg("projectedDimensions"), py::arg("format"), py::arg("lod"), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetProjectedVolumeSubsetBufferSize)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("requestProjectedVolumeSubset", static_cast(&VolumeDataAccessManager::RequestProjectedVolumeSubset), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("voxelPlane").none(false), py::arg("projectedDimensions").none(false), py::arg("format").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestProjectedVolumeSubset)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("requestProjectedVolumeSubset", static_cast(&VolumeDataAccessManager::RequestProjectedVolumeSubset), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("voxelPlane").none(false), py::arg("projectedDimensions").none(false), py::arg("format").none(false), py::arg("interpolationMethod").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestProjectedVolumeSubset_2)); - VolumeDataAccessManager_.def("getVolumeSamplesBufferSize" , static_cast(&VolumeDataAccessManager::GetVolumeSamplesBufferSize), py::arg("volumeDataLayout").none(false), py::arg("sampleCount").none(false), py::arg("channel").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVolumeSamplesBufferSize)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("requestVolumeSamples" , static_cast(&VolumeDataAccessManager::RequestVolumeSamples), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("samplePositions").none(false), py::arg("sampleCount").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSamples)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("requestVolumeSamples" , static_cast(&VolumeDataAccessManager::RequestVolumeSamples), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("samplePositions").none(false), py::arg("sampleCount").none(false), py::arg("interpolationMethod").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSamples_2)); - VolumeDataAccessManager_.def("getVolumeTracesBufferSize" , static_cast(&VolumeDataAccessManager::GetVolumeTracesBufferSize), py::arg("volumeDataLayout").none(false), py::arg("traceCount").none(false), py::arg("traceDimension").none(false), py::arg("lod").none(false), py::arg("channel").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetVolumeTracesBufferSize)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("requestVolumeTraces" , static_cast(&VolumeDataAccessManager::RequestVolumeTraces), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("tracePositions").none(false), py::arg("traceCount").none(false), py::arg("interpolationMethod").none(false), py::arg("traceDimension").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeTraces)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("requestVolumeTraces" , static_cast(&VolumeDataAccessManager::RequestVolumeTraces), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("tracePositions").none(false), py::arg("traceCount").none(false), py::arg("interpolationMethod").none(false), py::arg("traceDimension").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeTraces_2)); - VolumeDataAccessManager_.def("prefetchVolumeChunk" , static_cast(&VolumeDataAccessManager::PrefetchVolumeChunk), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("chunk").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_PrefetchVolumeChunk)); - VolumeDataAccessManager_.def("isCompleted" , static_cast(&VolumeDataAccessManager::IsCompleted), py::arg("requestID").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_IsCompleted)); - VolumeDataAccessManager_.def("isCanceled" , static_cast(&VolumeDataAccessManager::IsCanceled), py::arg("requestID").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_IsCanceled)); - VolumeDataAccessManager_.def("waitForCompletion" , static_cast(&VolumeDataAccessManager::WaitForCompletion), py::arg("requestID").none(false), py::arg("millisecondsBeforeTimeout").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_WaitForCompletion)); - VolumeDataAccessManager_.def("cancel" , static_cast(&VolumeDataAccessManager::Cancel), py::arg("requestID").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_Cancel)); - VolumeDataAccessManager_.def("getCompletionFactor" , static_cast(&VolumeDataAccessManager::GetCompletionFactor), py::arg("requestID").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetCompletionFactor)); - VolumeDataAccessManager_.def("flushUploadQueue" , static_cast(&VolumeDataAccessManager::FlushUploadQueue), py::arg("writeUpdatedLayerStatus").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_FlushUploadQueue)); - VolumeDataAccessManager_.def("clearUploadErrors" , static_cast(&VolumeDataAccessManager::ClearUploadErrors), OPENVDS_DOCSTRING(VolumeDataAccessManager_ClearUploadErrors)); - VolumeDataAccessManager_.def("forceClearAllUploadErrors" , static_cast(&VolumeDataAccessManager::ForceClearAllUploadErrors), OPENVDS_DOCSTRING(VolumeDataAccessManager_ForceClearAllUploadErrors)); - VolumeDataAccessManager_.def("uploadErrorCount" , static_cast(&VolumeDataAccessManager::UploadErrorCount), OPENVDS_DOCSTRING(VolumeDataAccessManager_UploadErrorCount)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("getCurrentUploadError" , static_cast(&VolumeDataAccessManager::GetCurrentUploadError), py::arg("objectId").none(false), py::arg("errorCode").none(false), py::arg("errorString").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetCurrentUploadError)); -// AUTOGENERATE FAIL : VolumeDataAccessManager_.def("getCurrentDownloadError" , static_cast(&VolumeDataAccessManager::GetCurrentDownloadError), py::arg("code").none(false), py::arg("errorString").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetCurrentDownloadError)); - - py::enum_ - VolumeDataAccessManager_AccessMode_(VolumeDataAccessManager_,"AccessMode", OPENVDS_DOCSTRING(VolumeDataAccessManager_AccessMode)); - - VolumeDataAccessManager_AccessMode_.value("AccessMode_ReadOnly" , VolumeDataAccessManager::AccessMode::AccessMode_ReadOnly, OPENVDS_DOCSTRING(VolumeDataAccessManager_AccessMode_AccessMode_ReadOnly)); - VolumeDataAccessManager_AccessMode_.value("AccessMode_ReadWrite" , VolumeDataAccessManager::AccessMode::AccessMode_ReadWrite, OPENVDS_DOCSTRING(VolumeDataAccessManager_AccessMode_AccessMode_ReadWrite)); - VolumeDataAccessManager_AccessMode_.value("AccessMode_Create" , VolumeDataAccessManager::AccessMode::AccessMode_Create, OPENVDS_DOCSTRING(VolumeDataAccessManager_AccessMode_AccessMode_Create)); + // IVolumeDataAccessor + py::class_> + IVolumeDataAccessor_(m,"IVolumeDataAccessor", OPENVDS_DOCSTRING(IVolumeDataAccessor)); + + IVolumeDataAccessor_.def("getManager" , static_cast(&IVolumeDataAccessor::GetManager), OPENVDS_DOCSTRING(IVolumeDataAccessor_GetManager)); + IVolumeDataAccessor_.def_property_readonly("manager", &IVolumeDataAccessor::GetManager, OPENVDS_DOCSTRING(IVolumeDataAccessor_GetManager)); + IVolumeDataAccessor_.def("getLayout" , static_cast(&IVolumeDataAccessor::GetLayout), OPENVDS_DOCSTRING(IVolumeDataAccessor_GetLayout)); + IVolumeDataAccessor_.def_property_readonly("layout", &IVolumeDataAccessor::GetLayout, OPENVDS_DOCSTRING(IVolumeDataAccessor_GetLayout)); + + // IVolumeDataAccessor::Manager + py::class_> + IVolumeDataAccessor_Manager_(IVolumeDataAccessor_,"IVolumeDataAccessor::Manager", OPENVDS_DOCSTRING(IVolumeDataAccessor_Manager)); + + IVolumeDataAccessor_Manager_.def("destroyVolumeDataAccessor" , static_cast(&IVolumeDataAccessor::Manager::DestroyVolumeDataAccessor), py::arg("accessor").none(false), OPENVDS_DOCSTRING(IVolumeDataAccessor_Manager_DestroyVolumeDataAccessor)); + IVolumeDataAccessor_Manager_.def("cloneVolumeDataAccessor" , static_cast(&IVolumeDataAccessor::Manager::CloneVolumeDataAccessor), py::arg("accessor").none(false), OPENVDS_DOCSTRING(IVolumeDataAccessor_Manager_CloneVolumeDataAccessor)); + + // IVolumeDataAccessor::IndexOutOfRangeException + py::class_> + IVolumeDataAccessor_IndexOutOfRangeException_(IVolumeDataAccessor_,"IVolumeDataAccessor::IndexOutOfRangeException", OPENVDS_DOCSTRING(IVolumeDataAccessor_IndexOutOfRangeException)); + + // IVolumeDataAccessor::ReadErrorException + py::class_> + IVolumeDataAccessor_ReadErrorException_(IVolumeDataAccessor_,"IVolumeDataAccessor::ReadErrorException", OPENVDS_DOCSTRING(IVolumeDataAccessor_ReadErrorException)); + + IVolumeDataAccessor_ReadErrorException_.def_readwrite("message" , &IVolumeDataAccessor::ReadErrorException::message, OPENVDS_DOCSTRING(IVolumeDataAccessor_ReadErrorException_message)); + IVolumeDataAccessor_ReadErrorException_.def_readwrite("errorCode" , &IVolumeDataAccessor::ReadErrorException::errorCode, OPENVDS_DOCSTRING(IVolumeDataAccessor_ReadErrorException_errorCode)); // VolumeDataPage py::class_> diff --git a/python/openvds/PyVolumeDataAccessManager.cpp b/python/openvds/PyVolumeDataAccessManager.cpp new file mode 100644 index 00000000..f539648a --- /dev/null +++ b/python/openvds/PyVolumeDataAccessManager.cpp @@ -0,0 +1,407 @@ +/**************************************************************************** +** Copyright 2019 The Open Group +** Copyright 2019 Bluware, Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +****************************************************************************/ + +#include "PyVolumeDataAccessManager.h" + +using namespace native; + +template +static void +RegisterVolumeDataRegions(py::module& m, const char* name) +{ + typedef typename VectorAdapter::AdaptedType AdaptedIndexType; + typedef VolumeDataRegions RegionsType; + typedef std::tuple IndexRegionType; + + py::class_> + VolumeDataRegions_(m, name, OPENVDS_DOCSTRING(VolumeDataRegions)); + + VolumeDataRegions_.def_property_readonly("regionCount", &RegionsType::RegionCount); + VolumeDataRegions_.def("region", [](RegionsType* self, int64_t region) + { + auto r = self->Region(region); + IndexRegionType result = std::make_tuple((AdaptedIndexType)r.Min, (AdaptedIndexType)r.Max); + return result; + }, OPENVDS_DOCSTRING(VolumeDataRegions_Region) + ); + VolumeDataRegions_.def("regionFromIndex", [](RegionsType* self, AdaptedIndexType index) + { + return self->RegionFromIndex(index); + }, OPENVDS_DOCSTRING(VolumeDataRegions_RegionFromIndex) + ); +} + +template +static void +RegisterVolumeDataAccessorWithRegions(py::module& m, const char* name) +{ + typedef typename VectorAdapter::AdaptedType AdaptedIndexType; + typedef VolumeDataRegions RegionsType; + typedef VolumeDataAccessorWithRegions AccessorWithRegionsType; + typedef std::tuple IndexRegionType; + + py::class_> + VolumeDataAccessorWithRegions_(m, name, OPENVDS_DOCSTRING(VolumeDataAccessorWithRegions)); + + VolumeDataAccessorWithRegions_.def_property_readonly("currentRegion", [](AccessorWithRegionsType* self) + { + auto r = self->CurrentRegion(); + IndexRegionType result = std::make_tuple((AdaptedIndexType)r.Min, (AdaptedIndexType)r.Max); + return result; + }, OPENVDS_DOCSTRING(VolumeDataAccessorWithRegions_CurrentRegion) + ); +} + +template +static void +RegisterVolumeDataReadAccessor(py::module& m, const char* name) +{ + typedef typename VectorAdapter::AdaptedType AdaptedIndexType; + typedef VolumeDataAccessorWithRegions AccessorWithRegionsType; + typedef VolumeDataReadAccessor AccessorType; + + py::class_> + VolumeDataAccessor_(m, name, OPENVDS_DOCSTRING(VolumeDataAccessor)); + + VolumeDataAccessor_.def("getValue", [](AccessorType* self, AdaptedIndexType index) + { + return self->GetValue(index); + } + ); +} + +template +static void +RegisterVolumeDataReadWriteAccessor(py::module& m, const char* name) +{ + typedef typename VectorAdapter::AdaptedType AdaptedIndexType; + typedef VolumeDataReadWriteAccessor AccessorType; + typedef VolumeDataReadAccessor BaseType; + + py::class_> + VolumeDataAccessor_(m, name, OPENVDS_DOCSTRING(VolumeDataAccessor)); + + VolumeDataAccessor_.def("setValue", [](AccessorType* self, AdaptedIndexType index, T value) + { + self->SetValue(index, value); + }); + VolumeDataAccessor_.def("commit", &AccessorType::Commit); + VolumeDataAccessor_.def("cancel", &AccessorType::Cancel); +} + +void +PyVolumeDataAccessManager::initModule(py::module& m) +{ +//AUTOGEN-BEGIN + py::enum_ + VDSProduceStatus_(m,"VDSProduceStatus", OPENVDS_DOCSTRING(VDSProduceStatus)); + + VDSProduceStatus_.value("Normal" , VDSProduceStatus::Normal , OPENVDS_DOCSTRING(VDSProduceStatus_Normal)); + VDSProduceStatus_.value("Remapped" , VDSProduceStatus::Remapped , OPENVDS_DOCSTRING(VDSProduceStatus_Remapped)); + VDSProduceStatus_.value("Unavailable" , VDSProduceStatus::Unavailable , OPENVDS_DOCSTRING(VDSProduceStatus_Unavailable)); + + // IVolumeDataAccessor + py::class_> + IVolumeDataAccessor_(m,"IVolumeDataAccessor", OPENVDS_DOCSTRING(IVolumeDataAccessor)); + + IVolumeDataAccessor_.def("getManager" , static_cast(&IVolumeDataAccessor::GetManager), OPENVDS_DOCSTRING(IVolumeDataAccessor_GetManager)); + IVolumeDataAccessor_.def_property_readonly("manager", &IVolumeDataAccessor::GetManager, OPENVDS_DOCSTRING(IVolumeDataAccessor_GetManager)); + IVolumeDataAccessor_.def("getLayout" , static_cast(&IVolumeDataAccessor::GetLayout), OPENVDS_DOCSTRING(IVolumeDataAccessor_GetLayout)); + IVolumeDataAccessor_.def_property_readonly("layout", &IVolumeDataAccessor::GetLayout, OPENVDS_DOCSTRING(IVolumeDataAccessor_GetLayout)); + + // IVolumeDataAccessor::Manager + py::class_> + IVolumeDataAccessor_Manager_(IVolumeDataAccessor_,"IVolumeDataAccessor::Manager", OPENVDS_DOCSTRING(IVolumeDataAccessor_Manager)); + + IVolumeDataAccessor_Manager_.def("destroyVolumeDataAccessor" , static_cast(&IVolumeDataAccessor::Manager::DestroyVolumeDataAccessor), py::arg("accessor").none(false), OPENVDS_DOCSTRING(IVolumeDataAccessor_Manager_DestroyVolumeDataAccessor)); + IVolumeDataAccessor_Manager_.def("cloneVolumeDataAccessor" , static_cast(&IVolumeDataAccessor::Manager::CloneVolumeDataAccessor), py::arg("accessor").none(false), OPENVDS_DOCSTRING(IVolumeDataAccessor_Manager_CloneVolumeDataAccessor)); + + // IVolumeDataAccessor::IndexOutOfRangeException + py::class_> + IVolumeDataAccessor_IndexOutOfRangeException_(IVolumeDataAccessor_,"IVolumeDataAccessor::IndexOutOfRangeException", OPENVDS_DOCSTRING(IVolumeDataAccessor_IndexOutOfRangeException)); + + // IVolumeDataAccessor::ReadErrorException + py::class_> + IVolumeDataAccessor_ReadErrorException_(IVolumeDataAccessor_,"IVolumeDataAccessor::ReadErrorException", OPENVDS_DOCSTRING(IVolumeDataAccessor_ReadErrorException)); + + IVolumeDataAccessor_ReadErrorException_.def_readwrite("message" , &IVolumeDataAccessor::ReadErrorException::message, OPENVDS_DOCSTRING(IVolumeDataAccessor_ReadErrorException_message)); + IVolumeDataAccessor_ReadErrorException_.def_readwrite("errorCode" , &IVolumeDataAccessor::ReadErrorException::errorCode, OPENVDS_DOCSTRING(IVolumeDataAccessor_ReadErrorException_errorCode)); + + // VolumeDataPage + py::class_> + VolumeDataPage_(m,"VolumeDataPage", OPENVDS_DOCSTRING(VolumeDataPage)); + + VolumeDataPage_.def("getMinMax" , [](VolumeDataPage* self, py::array_t& min, py::array_t& max) { return self->GetMinMax(PyArrayAdapter::getArrayChecked(min), PyArrayAdapter::getArrayChecked(max)); }, py::arg("min"), py::arg("max"), OPENVDS_DOCSTRING(VolumeDataPage_GetMinMax)); + VolumeDataPage_.def("getMinMaxExcludingMargin" , [](VolumeDataPage* self, py::array_t& minExcludingMargin, py::array_t& maxExcludingMargin) { return self->GetMinMaxExcludingMargin(PyArrayAdapter::getArrayChecked(minExcludingMargin), PyArrayAdapter::getArrayChecked(maxExcludingMargin)); }, py::arg("minExcludingMargin"), py::arg("maxExcludingMargin"), OPENVDS_DOCSTRING(VolumeDataPage_GetMinMaxExcludingMargin)); + VolumeDataPage_.def("getBuffer" , [](VolumeDataPage* self, py::array_t& pitch) { return self->GetBuffer(PyArrayAdapter::getArrayChecked(pitch)); }, py::arg("pitch"), OPENVDS_DOCSTRING(VolumeDataPage_GetBuffer)); + VolumeDataPage_.def("getWritableBuffer" , [](VolumeDataPage* self, py::array_t& pitch) { return self->GetWritableBuffer(PyArrayAdapter::getArrayChecked(pitch)); }, py::arg("pitch"), OPENVDS_DOCSTRING(VolumeDataPage_GetWritableBuffer)); + VolumeDataPage_.def("updateWrittenRegion" , [](VolumeDataPage* self, const py::array_t& writtenMin, const py::array_t& writtenMax) { return self->UpdateWrittenRegion(PyArrayAdapter::getArrayChecked(writtenMin), PyArrayAdapter::getArrayChecked(writtenMax)); }, py::arg("writtenMin"), py::arg("writtenMax"), OPENVDS_DOCSTRING(VolumeDataPage_UpdateWrittenRegion)); + VolumeDataPage_.def("release" , static_cast(&VolumeDataPage::Release), OPENVDS_DOCSTRING(VolumeDataPage_Release)); + + // VolumeDataPageAccessor + py::class_> + VolumeDataPageAccessor_(m,"VolumeDataPageAccessor", OPENVDS_DOCSTRING(VolumeDataPageAccessor)); + + VolumeDataPageAccessor_.def("getLayout" , static_cast(&VolumeDataPageAccessor::GetLayout), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetLayout)); + VolumeDataPageAccessor_.def_property_readonly("layout", &VolumeDataPageAccessor::GetLayout, OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetLayout)); + VolumeDataPageAccessor_.def("getLOD" , static_cast(&VolumeDataPageAccessor::GetLOD), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetLOD)); + VolumeDataPageAccessor_.def_property_readonly("LOD", &VolumeDataPageAccessor::GetLOD, OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetLOD)); + VolumeDataPageAccessor_.def("getChannelIndex" , static_cast(&VolumeDataPageAccessor::GetChannelIndex), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChannelIndex)); + VolumeDataPageAccessor_.def_property_readonly("channelIndex", &VolumeDataPageAccessor::GetChannelIndex, OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChannelIndex)); + VolumeDataPageAccessor_.def("getChannelDescriptor" , static_cast(&VolumeDataPageAccessor::GetChannelDescriptor), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChannelDescriptor)); + VolumeDataPageAccessor_.def_property_readonly("channelDescriptor", &VolumeDataPageAccessor::GetChannelDescriptor, OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChannelDescriptor)); + VolumeDataPageAccessor_.def("getNumSamples" , [](VolumeDataPageAccessor* self, py::array_t& numSamples) { return self->GetNumSamples(PyArrayAdapter::getArrayChecked(numSamples)); }, py::arg("numSamples"), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetNumSamples)); + VolumeDataPageAccessor_.def("getChunkCount" , static_cast(&VolumeDataPageAccessor::GetChunkCount), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChunkCount)); + VolumeDataPageAccessor_.def_property_readonly("chunkCount", &VolumeDataPageAccessor::GetChunkCount, OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChunkCount)); + VolumeDataPageAccessor_.def("getChunkMinMax" , [](VolumeDataPageAccessor* self, int64_t chunk, py::array_t& min, py::array_t& max) { return self->GetChunkMinMax(chunk, PyArrayAdapter::getArrayChecked(min), PyArrayAdapter::getArrayChecked(max)); }, py::arg("chunk"), py::arg("min"), py::arg("max"), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChunkMinMax)); + VolumeDataPageAccessor_.def("getChunkMinMaxExcludingMargin", [](VolumeDataPageAccessor* self, int64_t chunk, py::array_t& minExcludingMargin, py::array_t& maxExcludingMargin) { return self->GetChunkMinMaxExcludingMargin(chunk, PyArrayAdapter::getArrayChecked(minExcludingMargin), PyArrayAdapter::getArrayChecked(maxExcludingMargin)); }, py::arg("chunk"), py::arg("minExcludingMargin"), py::arg("maxExcludingMargin"), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChunkMinMaxExcludingMargin)); + VolumeDataPageAccessor_.def("getChunkIndex" , [](VolumeDataPageAccessor* self, const py::array_t& position) { return self->GetChunkIndex(PyArrayAdapter::getArrayChecked(position)); }, py::arg("position"), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetChunkIndex)); + VolumeDataPageAccessor_.def("addReference" , static_cast(&VolumeDataPageAccessor::AddReference), OPENVDS_DOCSTRING(VolumeDataPageAccessor_AddReference)); + VolumeDataPageAccessor_.def("removeReference" , static_cast(&VolumeDataPageAccessor::RemoveReference), OPENVDS_DOCSTRING(VolumeDataPageAccessor_RemoveReference)); + VolumeDataPageAccessor_.def("getMaxPages" , static_cast(&VolumeDataPageAccessor::GetMaxPages), OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetMaxPages)); + VolumeDataPageAccessor_.def_property_readonly("maxPages", &VolumeDataPageAccessor::GetMaxPages, OPENVDS_DOCSTRING(VolumeDataPageAccessor_GetMaxPages)); + VolumeDataPageAccessor_.def("setMaxPages" , static_cast(&VolumeDataPageAccessor::SetMaxPages), py::arg("maxPages").none(false), OPENVDS_DOCSTRING(VolumeDataPageAccessor_SetMaxPages)); + VolumeDataPageAccessor_.def("createPage" , static_cast(&VolumeDataPageAccessor::CreatePage), py::arg("chunkIndex").none(false), OPENVDS_DOCSTRING(VolumeDataPageAccessor_CreatePage)); + VolumeDataPageAccessor_.def("readPage" , static_cast(&VolumeDataPageAccessor::ReadPage), py::arg("chunkIndex").none(false), OPENVDS_DOCSTRING(VolumeDataPageAccessor_ReadPage)); + VolumeDataPageAccessor_.def("readPageAtPosition" , [](VolumeDataPageAccessor* self, const py::array_t& position) { return self->ReadPageAtPosition(PyArrayAdapter::getArrayChecked(position)); }, py::arg("position"), OPENVDS_DOCSTRING(VolumeDataPageAccessor_ReadPageAtPosition)); + VolumeDataPageAccessor_.def("commit" , static_cast(&VolumeDataPageAccessor::Commit), OPENVDS_DOCSTRING(VolumeDataPageAccessor_Commit)); + +//AUTOGEN-END + +// IMPLEMENTED : VolumeDataAccessManager_.def("createVolumeDataPageAccessor", static_cast(&VolumeDataAccessManager::CreateVolumeDataPageAccessor), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("maxPages").none(false), py::arg("accessMode").none(false), py::arg("chunkMetadataPageSize").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_CreateVolumeDataPageAccessor)); + VolumeDataAccessManager_.def("createVolumeDataPageAccessor", static_cast(&VolumeDataAccessManager::CreateVolumeDataPageAccessor), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("maxPages").none(false), py::arg("accessMode").none(false), py::arg("chunkMetadataPageSize").none(false) = 1024, OPENVDS_DOCSTRING(VolumeDataAccessManager_CreateVolumeDataPageAccessor)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("requestVolumeSubset" , static_cast(&VolumeDataAccessManager::RequestVolumeSubset), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("format").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSubset)); + VolumeDataAccessManager_.def("requestVolumeSubset" , [] (VolumeDataAccessManager* self, py::buffer buf, const native::VolumeDataLayout *layout, native::DimensionsND dimensions, int lod, int channel, py::array_t& arg1, py::array_t& arg2, VolumeDataChannelDescriptor::Format fmt) + { + auto& minVoxelCoordinates = PyArrayAdapter::getArrayChecked(arg1); + auto& maxVoxelCoordinates = PyArrayAdapter::getArrayChecked(arg2); + int64_t bufferSize = self->GetVolumeSubsetBufferSize(layout, minVoxelCoordinates, maxVoxelCoordinates, fmt, lod); + py::buffer_info info = buf.request(true); + if (info.size * info.itemsize < bufferSize) + { + throw std::runtime_error("Insufficient buffer"); + } + return self->RequestVolumeSubset(info.ptr, layout, dimensions, lod, channel, minVoxelCoordinates, maxVoxelCoordinates, fmt); + } + , py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("format").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSubset)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("requestVolumeSubset" , static_cast(&VolumeDataAccessManager::RequestVolumeSubset), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lOD").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("format").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSubset_2)); + VolumeDataAccessManager_.def("requestVolumeSubset" , [] (VolumeDataAccessManager* self, py::buffer buf, const native::VolumeDataLayout *layout, native::DimensionsND dimensions, int lod, int channel, py::array_t& arg1, py::array_t& arg2, VolumeDataChannelDescriptor::Format fmt, float replacementNoValue) + { + auto& minVoxelCoordinates = PyArrayAdapter::getArrayChecked(arg1); + auto& maxVoxelCoordinates = PyArrayAdapter::getArrayChecked(arg2); + int64_t bufferSize = self->GetVolumeSubsetBufferSize(layout, minVoxelCoordinates, maxVoxelCoordinates, fmt, lod); + py::buffer_info info = buf.request(true); + if (info.size * info.itemsize < bufferSize) + { + throw std::runtime_error("Insufficient buffer"); + } + return self->RequestVolumeSubset(info.ptr, layout, dimensions, lod, channel, minVoxelCoordinates, maxVoxelCoordinates, fmt, replacementNoValue); + } + , py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lOD").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("format").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSubset)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("requestProjectedVolumeSubset", static_cast(&VolumeDataAccessManager::RequestProjectedVolumeSubset), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("voxelPlane").none(false), py::arg("projectedDimensions").none(false), py::arg("format").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestProjectedVolumeSubset)); + VolumeDataAccessManager_.def("requestProjectedVolumeSubset" , [] (VolumeDataAccessManager* self, py::buffer buf, const native::VolumeDataLayout *layout, native::DimensionsND dimensions, int lod, int channel, py::array_t& arg1, py::array_t& arg2, const FloatVector4Adapter::AdaptedType &voxelPlane, native::DimensionsND projectedDimensions, VolumeDataChannelDescriptor::Format fmt, native::InterpolationMethod interpolationMethod) + { + auto& minVoxelCoordinates = PyArrayAdapter::getArrayChecked(arg1); + auto& maxVoxelCoordinates = PyArrayAdapter::getArrayChecked(arg2); + int64_t bufferSize = self->GetProjectedVolumeSubsetBufferSize(layout, minVoxelCoordinates, maxVoxelCoordinates, projectedDimensions, fmt, lod); + py::buffer_info info = buf.request(true); + if (info.size * info.itemsize < bufferSize) + { + throw std::runtime_error("Insufficient buffer"); + } + return self->RequestProjectedVolumeSubset(info.ptr, layout, dimensions, lod, channel, minVoxelCoordinates, maxVoxelCoordinates, voxelPlane, projectedDimensions, fmt, interpolationMethod); + } + , py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("voxelPlane").none(false), py::arg("projectedDimensions").none(false), py::arg("format").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestProjectedVolumeSubset)); +// IMPLEMENTED : VolumeDataAccessManager_.def("requestProjectedVolumeSubset", static_cast(&VolumeDataAccessManager::RequestProjectedVolumeSubset), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("voxelPlane").none(false), py::arg("projectedDimensions").none(false), py::arg("format").none(false), py::arg("interpolationMethod").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestProjectedVolumeSubset_2)); + VolumeDataAccessManager_.def("requestProjectedVolumeSubset" , [] (VolumeDataAccessManager* self, py::buffer buf, const native::VolumeDataLayout *layout, native::DimensionsND dimensions, int lod, int channel, py::array_t& arg1, py::array_t& arg2, const FloatVector4Adapter::AdaptedType &voxelPlane, native::DimensionsND projectedDimensions, VolumeDataChannelDescriptor::Format fmt, native::InterpolationMethod interpolationMethod, float replacementNoValue) + { + auto& minVoxelCoordinates = PyArrayAdapter::getArrayChecked(arg1); + auto& maxVoxelCoordinates = PyArrayAdapter::getArrayChecked(arg2); + int64_t bufferSize = self->GetProjectedVolumeSubsetBufferSize(layout, minVoxelCoordinates, maxVoxelCoordinates, projectedDimensions, fmt, lod); + py::buffer_info info = buf.request(true); + if (info.size * info.itemsize < bufferSize) + { + throw std::runtime_error("Insufficient buffer"); + } + return self->RequestProjectedVolumeSubset(info.ptr, layout, dimensions, lod, channel, minVoxelCoordinates, maxVoxelCoordinates, voxelPlane, projectedDimensions, fmt, interpolationMethod, replacementNoValue); + } + , py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("minVoxelCoordinates").none(false), py::arg("maxVoxelCoordinates").none(false), py::arg("voxelPlane").none(false), py::arg("projectedDimensions").none(false), py::arg("format").none(false), py::arg("interpolationMethod").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestProjectedVolumeSubset_2)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("requestVolumeSamples" , static_cast(&VolumeDataAccessManager::RequestVolumeSamples), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("samplePositions").none(false), py::arg("sampleCount").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSamples)); + VolumeDataAccessManager_.def("requestVolumeSamples" , [] (VolumeDataAccessManager* self, py::buffer buf, const native::VolumeDataLayout *layout, native::DimensionsND dimensions, int lod, int channel, py::array_t& sampleCoordinates, native::InterpolationMethod interpolationMethod) + { + int sampleCount = 0; + auto& voxelCoordinates = PyArrayAdapter::getArrayChecked(sampleCoordinates, &sampleCount); + int64_t bufferSize = sizeof(float) * sampleCount; + py::buffer_info info = buf.request(true); + if (info.size * info.itemsize < bufferSize) + { + throw std::runtime_error("Insufficient buffer"); + } + return self->RequestVolumeSamples((float*)info.ptr, layout, dimensions, lod, channel, &voxelCoordinates, sampleCount, interpolationMethod); + } + , py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("samplePositions").none(false), py::arg("interpolationMethod").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSamples)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("requestVolumeSamples" , static_cast(&VolumeDataAccessManager::RequestVolumeSamples), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("samplePositions").none(false), py::arg("sampleCount").none(false), py::arg("interpolationMethod").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSamples_2)); + VolumeDataAccessManager_.def("requestVolumeSamples" , [] (VolumeDataAccessManager* self, py::buffer buf, const native::VolumeDataLayout *layout, native::DimensionsND dimensions, int lod, int channel, py::array_t& sampleCoordinates, native::InterpolationMethod interpolationMethod, float replacementNoValue) + { + int sampleCount = 0; + auto& voxelCoordinates = PyArrayAdapter::getArrayChecked(sampleCoordinates, &sampleCount); + int64_t bufferSize = sizeof(float) * sampleCount; + py::buffer_info info = buf.request(true); + if (info.size * info.itemsize < bufferSize) + { + throw std::runtime_error("Insufficient buffer"); + } + return self->RequestVolumeSamples((float*)info.ptr, layout, dimensions, lod, channel, &voxelCoordinates, sampleCount, interpolationMethod, replacementNoValue); + } + , py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("samplePositions").none(false), py::arg("interpolationMethod").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeSamples_2)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("requestVolumeTraces" , static_cast(&VolumeDataAccessManager::RequestVolumeTraces), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("tracePositions").none(false), py::arg("traceCount").none(false), py::arg("interpolationMethod").none(false), py::arg("traceDimension").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeTraces)); + VolumeDataAccessManager_.def("requestVolumeTraces" , [] (VolumeDataAccessManager* self, py::buffer buf, const native::VolumeDataLayout *layout, native::DimensionsND dimensions, int lod, int channel, py::array_t& tracePositions, native::InterpolationMethod interpolationMethod, int traceDimension) + { + int traceCount = 0; + auto& traceCoordinates = PyArrayAdapter::getArrayChecked(tracePositions, &traceCount); + int64_t bufferSize = self->GetVolumeTracesBufferSize(layout, traceCount, traceDimension, lod); + py::buffer_info info = buf.request(true); + if (info.size * info.itemsize < bufferSize) + { + throw std::runtime_error("Insufficient buffer"); + } + return self->RequestVolumeTraces((float*)info.ptr, layout, dimensions, lod, channel, &traceCoordinates, traceCount, interpolationMethod, traceDimension); + } + , py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("tracePositions").none(false), py::arg("interpolationMethod").none(false), py::arg("traceDimension").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeTraces)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("requestVolumeTraces" , static_cast(&VolumeDataAccessManager::RequestVolumeTraces), py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("tracePositions").none(false), py::arg("traceCount").none(false), py::arg("interpolationMethod").none(false), py::arg("traceDimension").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeTraces_2)); + VolumeDataAccessManager_.def("requestVolumeTraces" , [] (VolumeDataAccessManager* self, py::buffer buf, const native::VolumeDataLayout *layout, native::DimensionsND dimensions, int lod, int channel, py::array_t& tracePositions, native::InterpolationMethod interpolationMethod, int traceDimension, float replacementNoValue) + { + int traceCount = 0; + auto& traceCoordinates = PyArrayAdapter::getArrayChecked(tracePositions, &traceCount); + int64_t bufferSize = self->GetVolumeTracesBufferSize(layout, traceCount, traceDimension, lod); + py::buffer_info info = buf.request(true); + if (info.size * info.itemsize < bufferSize) + { + throw std::runtime_error("Insufficient buffer"); + } + return self->RequestVolumeTraces((float*)info.ptr, layout, dimensions, lod, channel, &traceCoordinates, traceCount, interpolationMethod, traceDimension, replacementNoValue); + } + , py::arg("buffer").none(false), py::arg("volumeDataLayout").none(false), py::arg("dimensionsND").none(false), py::arg("lod").none(false), py::arg("channel").none(false), py::arg("tracePositions").none(false), py::arg("interpolationMethod").none(false), py::arg("traceDimension").none(false), py::arg("replacementNoValue").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_RequestVolumeTraces_2)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("flushUploadQueue" , static_cast(&VolumeDataAccessManager::FlushUploadQueue), py::arg("writeUpdatedLayerStatus").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_FlushUploadQueue)); +VolumeDataAccessManager_.def("flushUploadQueue" , static_cast(&VolumeDataAccessManager::FlushUploadQueue), py::arg("writeUpdatedLayerStatus").none(false) = true, OPENVDS_DOCSTRING(VolumeDataAccessManager_FlushUploadQueue)); + +// IMPLEMENTED : VolumeDataAccessManager_.def("getCurrentUploadError" , static_cast(&VolumeDataAccessManager::GetCurrentUploadError), py::arg("objectId").none(false), py::arg("errorCode").none(false), py::arg("errorString").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetCurrentUploadError)); + VolumeDataAccessManager_.def("getCurrentUploadError" , [](VolumeDataAccessManager* self) + { + const char + *pObjectID = nullptr, + *pErrorString = nullptr; + + int32_t + errorCode = 0; + + self->GetCurrentUploadError(&pObjectID, &errorCode, &pErrorString); + return std::make_tuple(std::string(pObjectID), errorCode, std::string(pErrorString)); + }, OPENVDS_DOCSTRING(VolumeDataAccessManager_GetCurrentUploadError)); + + // IMPLEMENTED : VolumeDataAccessManager_.def("getCurrentDownloadError" , static_cast(&VolumeDataAccessManager::GetCurrentDownloadError), py::arg("code").none(false), py::arg("errorString").none(false), OPENVDS_DOCSTRING(VolumeDataAccessManager_GetCurrentDownloadError)); + VolumeDataAccessManager_.def("getCurrentDownloadError" , [](VolumeDataAccessManager* self) + { + const char + *pErrorString = nullptr; + + int32_t + errorCode = 0; + + self->GetCurrentDownloadError(&errorCode, &pErrorString); + return std::make_tuple(errorCode, std::string(pErrorString)); + }, OPENVDS_DOCSTRING(VolumeDataAccessManager_GetCurrentDownloadError)); + + VolumeDataAccessManager_.attr("Dimensionality_Max") = py::int_(VolumeDataAccessManager::Dimensionality_Max); + + // Register region types + RegisterVolumeDataRegions (m, "VolumeDataRegionsIntVector2"); + RegisterVolumeDataRegions (m, "VolumeDataRegionsIntVector3"); + RegisterVolumeDataRegions (m, "VolumeDataRegionsIntVector4"); + RegisterVolumeDataRegions (m, "VolumeDataRegionsFloatVector2"); + RegisterVolumeDataRegions (m, "VolumeDataRegionsFloatVector3"); + RegisterVolumeDataRegions (m, "VolumeDataRegionsFloatVector4"); + + // Register accessor base types + RegisterVolumeDataAccessorWithRegions (m, "VolumeDataAccessorWithRegionsIntVector2"); + RegisterVolumeDataAccessorWithRegions (m, "VolumeDataAccessorWithRegionsIntVector3"); + RegisterVolumeDataAccessorWithRegions (m, "VolumeDataAccessorWithRegionsIntVector4"); + RegisterVolumeDataAccessorWithRegions (m, "VolumeDataAccessorWithRegionsFloatVector2"); + RegisterVolumeDataAccessorWithRegions (m, "VolumeDataAccessorWithRegionsFloatVector3"); + RegisterVolumeDataAccessorWithRegions (m, "VolumeDataAccessorWithRegionsFloatVector4"); + + // Register accessor types + RegisterVolumeDataReadAccessor (m, "Read2DVolumeDataAccessor1Bit"); + RegisterVolumeDataReadAccessor (m, "Read2DVolumeDataAccessorU8"); + RegisterVolumeDataReadAccessor (m, "Read2DVolumeDataAccessorU16"); + RegisterVolumeDataReadAccessor (m, "Read2DVolumeDataAccessorU32"); + RegisterVolumeDataReadAccessor (m, "Read2DVolumeDataAccessorU64"); + RegisterVolumeDataReadAccessor (m, "Read2DVolumeDataAccessorR32"); + RegisterVolumeDataReadAccessor (m, "Read2DVolumeDataAccessorR64"); + RegisterVolumeDataReadAccessor (m, "Read3DVolumeDataAccessor1Bit"); + RegisterVolumeDataReadAccessor (m, "Read3DVolumeDataAccessorU8"); + RegisterVolumeDataReadAccessor (m, "Read3DVolumeDataAccessorU16"); + RegisterVolumeDataReadAccessor (m, "Read3DVolumeDataAccessorU32"); + RegisterVolumeDataReadAccessor (m, "Read3DVolumeDataAccessorU64"); + RegisterVolumeDataReadAccessor (m, "Read3DVolumeDataAccessorR32"); + RegisterVolumeDataReadAccessor (m, "Read3DVolumeDataAccessorR64"); + RegisterVolumeDataReadAccessor (m, "Read4DVolumeDataAccessor1Bit"); + RegisterVolumeDataReadAccessor (m, "Read4DVolumeDataAccessorU8"); + RegisterVolumeDataReadAccessor (m, "Read4DVolumeDataAccessorU16"); + RegisterVolumeDataReadAccessor (m, "Read4DVolumeDataAccessorU32"); + RegisterVolumeDataReadAccessor (m, "Read4DVolumeDataAccessorU64"); + RegisterVolumeDataReadAccessor (m, "Read4DVolumeDataAccessorR32"); + RegisterVolumeDataReadAccessor (m, "Read4DVolumeDataAccessorR64"); + RegisterVolumeDataReadAccessor (m, "Interpolating2DVolumeDataAccessorR32"); + RegisterVolumeDataReadAccessor (m, "Interpolating2DVolumeDataAccessorR64"); + RegisterVolumeDataReadAccessor (m, "Interpolating3DVolumeDataAccessorR32"); + RegisterVolumeDataReadAccessor (m, "Interpolating3DVolumeDataAccessorR64"); + RegisterVolumeDataReadAccessor (m, "Interpolating4DVolumeDataAccessorR32"); + RegisterVolumeDataReadAccessor (m, "Interpolating4DVolumeDataAccessorR64"); + + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite2DVolumeDataAccessor1Bit"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite2DVolumeDataAccessorU8"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite2DVolumeDataAccessorU16"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite2DVolumeDataAccessorU32"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite2DVolumeDataAccessorU64"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite2DVolumeDataAccessorR32"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite2DVolumeDataAccessorR64"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite3DVolumeDataAccessor1Bit"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite3DVolumeDataAccessorU8"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite3DVolumeDataAccessorU16"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite3DVolumeDataAccessorU32"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite3DVolumeDataAccessorU64"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite3DVolumeDataAccessorR32"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite3DVolumeDataAccessorR64"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite4DVolumeDataAccessor1Bit"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite4DVolumeDataAccessorU8"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite4DVolumeDataAccessorU16"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite4DVolumeDataAccessorU32"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite4DVolumeDataAccessorU64"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite4DVolumeDataAccessorR32"); + RegisterVolumeDataReadWriteAccessor (m, "ReadWrite4DVolumeDataAccessorR64"); + +} + diff --git a/python/openvds/PyVolumeDataAccessManager.h b/python/openvds/PyVolumeDataAccessManager.h new file mode 100644 index 00000000..5b3ebbe1 --- /dev/null +++ b/python/openvds/PyVolumeDataAccessManager.h @@ -0,0 +1,28 @@ +/**************************************************************************** +** Copyright 2019 The Open Group +** Copyright 2019 Bluware, Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +****************************************************************************/ +#ifndef PYVOLUMEDATAACCESSMANAGER_H_INCLUDED +#define PYVOLUMEDATAACCESSMANAGER_H_INCLUDED + +#include "PyGlobal.h" + +class PyVolumeDataAccessManager +{ +public: + static void initModule(py::module& m); +}; + +#endif diff --git a/python/openvds/core.cpp b/python/openvds/core.cpp index d8cc7f97..31bb200f 100644 --- a/python/openvds/core.cpp +++ b/python/openvds/core.cpp @@ -28,6 +28,7 @@ #include "PyVector.h" #include "PyVolumeData.h" #include "PyVolumeDataAccess.h" +#include "PyVolumeDataAccessManager.h" #include "PyVolumeDataAxisDescriptor.h" #include "PyVolumeDataChannelDescriptor.h" #include "PyVolumeDataLayout.h" @@ -46,6 +47,7 @@ PYBIND11_MODULE(core, m) { PyVector::initModule(m); PyVolumeData::initModule(m); PyVolumeDataAccess::initModule(m); + PyVolumeDataAccessManager::initModule(m); PyVolumeDataAxisDescriptor::initModule(m); PyVolumeDataChannelDescriptor::initModule(m); PyVolumeDataLayout::initModule(m); diff --git a/python/openvds/generated_docstrings.h b/python/openvds/generated_docstrings.h index cd654fb6..c45f98e8 100644 --- a/python/openvds/generated_docstrings.h +++ b/python/openvds/generated_docstrings.h @@ -324,6 +324,18 @@ static const char *__doc_OpenVDS_CreateInterpolatingVolumeDataAccessor_5 = R"doc static const char *__doc_OpenVDS_CreateInterpolatingVolumeDataAccessor_6 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateInterpolatingVolumeDataAccessor_7 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateInterpolatingVolumeDataAccessor_8 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateInterpolatingVolumeDataAccessor_9 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateInterpolatingVolumeDataAccessor_10 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateInterpolatingVolumeDataAccessor_11 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateInterpolatingVolumeDataAccessor_12 = R"doc()doc"; + static const char *__doc_OpenVDS_CreateOpenOptions = R"doc(Create an OpenOptions struct from a url and connection string @@ -347,47 +359,173 @@ Returns: the OpenOption before passing it to Open. Use the Open and Create functions with url and string instead if this is not needed.)doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_3 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_4 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_5 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_6 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_7 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_8 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_9 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_10 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_11 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_12 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_13 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_14 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_15 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_16 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_17 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_18 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_19 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_20 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_21 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_22 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_23 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_24 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_25 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_26 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_27 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_28 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_29 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_30 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_31 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_32 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_33 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_34 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_35 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_36 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_37 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_38 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_39 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_40 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_41 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadAccessor_42 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_3 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_4 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_5 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_6 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_7 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_8 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_9 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_10 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_11 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_12 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_13 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_14 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_15 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_16 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_17 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_2 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_18 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_3 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_19 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_4 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_20 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_5 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_21 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_6 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_22 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_7 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_23 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_8 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_24 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_9 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_25 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_10 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_26 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_11 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_27 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_12 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_28 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_13 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_29 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_14 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_30 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_15 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_31 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_16 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_32 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_17 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_33 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_18 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_34 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_19 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_35 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_20 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_36 = R"doc()doc"; -static const char *__doc_OpenVDS_CreateVolumeDataAccessor_21 = R"doc()doc"; +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_37 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_38 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_39 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_40 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_41 = R"doc()doc"; + +static const char *__doc_OpenVDS_CreateVolumeDataReadWriteAccessor_42 = R"doc()doc"; static const char *__doc_OpenVDS_DMSOpenOptions = R"doc()doc"; @@ -483,6 +621,20 @@ static const char *__doc_OpenVDS_Error_code = R"doc()doc"; static const char *__doc_OpenVDS_Error_string = R"doc()doc"; +static const char *__doc_OpenVDS_Exception = R"doc()doc"; + +static const char *__doc_OpenVDS_Exception_GetErrorMessage = R"doc()doc"; + +static const char *__doc_OpenVDS_Exception_what = R"doc()doc"; + +static const char *__doc_OpenVDS_FatalException = R"doc()doc"; + +static const char *__doc_OpenVDS_FatalException_FatalException = R"doc()doc"; + +static const char *__doc_OpenVDS_FatalException_GetErrorMessage = R"doc()doc"; + +static const char *__doc_OpenVDS_FatalException_m_errorMessage = R"doc()doc"; + static const char *__doc_OpenVDS_GenericDispatcher = R"doc()doc"; static const char *__doc_OpenVDS_GenericDispatcher_1 = R"doc()doc"; @@ -500,6 +652,19 @@ Returns: -------- The VolumeDataAccessManager of the VDS)doc"; +static const char *__doc_OpenVDS_GetAccessManagerInterface = +R"doc(Get the VolumeDataAccessManagerInterface for a VDS + +Parameters: +----------- + +handle : + The handle of the VDS + +Returns: +-------- + The VolumeDataAccessManagerInterface of the VDS)doc"; + static const char *__doc_OpenVDS_GetGlobalState = R"doc(Get the GlobalState interface @@ -738,86 +903,726 @@ static const char *__doc_OpenVDS_GoogleOpenOptions_CredentialsType_Path = R"doc( static const char *__doc_OpenVDS_GoogleOpenOptions_CredentialsType_SignedUrl = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_CredentialsType_SignedUrlJson = R"doc()doc"; +static const char *__doc_OpenVDS_GoogleOpenOptions_CredentialsType_SignedUrlJson = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_CredentialsType_SignedUrlPath = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_2 = +R"doc(GoogleOpenOptions constructor + +Parameters: +----------- + +bucket : + The bucket of the VDS + +pathPrefix : + The prefix of the VDS + +credentials : + Google Cloud Storage access credentials)doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_3 = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_4 = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_5 = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_6 = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_7 = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_8 = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_SetSignedUrl = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_bucket = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_credentials = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_credentialsType = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_pathPrefix = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_region = R"doc()doc"; + +static const char *__doc_OpenVDS_GoogleOpenOptions_storageClass = R"doc()doc"; + +static const char *__doc_OpenVDS_HttpOpenOptions = +R"doc(Options for opening a VDS with a plain http url. If there are query +parameters in then they will be appended to the different sub urls. +The resulting IO backend will not support uploading data.)doc"; + +static const char *__doc_OpenVDS_HttpOpenOptions_HttpOpenOptions = R"doc()doc"; + +static const char *__doc_OpenVDS_HttpOpenOptions_HttpOpenOptions_2 = +R"doc(HttpOpenOptions constructor + +Parameters: +----------- + +url : + The http base url of the VDS)doc"; + +static const char *__doc_OpenVDS_HttpOpenOptions_url = R"doc()doc"; + +static const char *__doc_OpenVDS_IHasVolumeDataAccess = R"doc()doc"; + +static const char *__doc_OpenVDS_IHasVolumeDataAccess_GetVolumeDataAccessManager = R"doc()doc"; + +static const char *__doc_OpenVDS_IHasVolumeDataAccess_IHasVolumeDataAccess = R"doc()doc"; + +static const char *__doc_OpenVDS_IJKGridDefinition = R"doc()doc"; + +static const char *__doc_OpenVDS_IJKGridDefinition_IJKGridDefinition = R"doc()doc"; + +static const char *__doc_OpenVDS_IJKGridDefinition_IJKGridDefinition_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_IJKGridDefinition_iUnitStep = R"doc()doc"; + +static const char *__doc_OpenVDS_IJKGridDefinition_jUnitStep = R"doc()doc"; + +static const char *__doc_OpenVDS_IJKGridDefinition_kUnitStep = R"doc()doc"; + +static const char *__doc_OpenVDS_IJKGridDefinition_origin = R"doc()doc"; + +static const char *__doc_OpenVDS_IOManager = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_AccessMode = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_AccessMode_AccessMode_Create = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_AccessMode_AccessMode_ReadOnly = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_AccessMode_AccessMode_ReadWrite = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_AddRef = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Cancel = +R"doc(Try to cancel the request. You still have to call +WaitForCompletion/IsCanceled to make sure the buffer is not being +written to and to take the job out of the system. It is possible that +the request has completed concurrently with the call to Cancel in +which case WaitForCompletion will return True. + +Parameters: +----------- + +requestID : + The RequestID to cancel.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_CancelAndWaitForCompletion = +R"doc(Cancel the request and wait for it to complete. This call will block +until the request has completed so you can be sure the buffer is not +being written to and the job is taken out of the system. + +Parameters: +----------- + +requestID : + The RequestID to cancel.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_ClearUploadErrors = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_CloneVolumeDataAccessor = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DInterpolatingVolumeDataAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DInterpolatingVolumeDataAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DVolumeDataAccessor1Bit = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DVolumeDataAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DVolumeDataAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DVolumeDataAccessorU16 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DVolumeDataAccessorU32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DVolumeDataAccessorU64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create2DVolumeDataAccessorU8 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DInterpolatingVolumeDataAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DInterpolatingVolumeDataAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DVolumeDataAccessor1Bit = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DVolumeDataAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DVolumeDataAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DVolumeDataAccessorU16 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DVolumeDataAccessorU32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DVolumeDataAccessorU64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create3DVolumeDataAccessorU8 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DInterpolatingVolumeDataAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DInterpolatingVolumeDataAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DVolumeDataAccessor1Bit = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DVolumeDataAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DVolumeDataAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DVolumeDataAccessorU16 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DVolumeDataAccessorU32 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DVolumeDataAccessorU64 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Create4DVolumeDataAccessorU8 = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_CreateVolumeDataPageAccessor = +R"doc(Create a volume data page accessor object for the VDS associated with +the given VolumeDataLayout object. + +Parameters: +----------- + +dimensionsND : + The dimensions group that the volume data page accessor will + access. + +LOD : + The LOD level that the volume data page accessor will access. + +channel : + The channel index that the volume data page accessor will access. + +maxPages : + The maximum number of pages that the volume data page accessor + will cache. + +accessMode : + This specifies the access mode (ReadOnly/ReadWrite/Create) of the + volume data page accessor. + +chunkMetadataPageSize : + The chunk metadata page size of the layer. This controls how many + chunk metadata entries are written per page, and is only used when + the access mode is Create. If this number is too low it will + degrade performance, but in certain situations it can be + advantageous to make this number a multiple of the number of + chunks in some of the dimensions. Do not change this from the + default (1024) unless you know exactly what you are doing. + +Returns: +-------- + A VolumeDataPageAccessor object for the VDS associated with the + given VolumeDataLayout object.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_DestroyVolumeDataAccessor = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_DestroyVolumeDataPageAccessor = +R"doc(Destroy a volume data page accessor object. + +Parameters: +----------- + +volumeDataPageAccessor : + The VolumeDataPageAccessor object to destroy.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_FlushUploadQueue = +R"doc(Flush any pending writes and write updated layer status + +Parameters: +----------- + +writeUpdatedLayerStatus : + Write the updated layer status (or only flush pending writes of + chunks and chunk-metadata).)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_ForceClearAllUploadErrors = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetCompletionFactor = +R"doc(Get the completion factor (between 0 and 1) of the request. + +Parameters: +----------- + +requestID : + The RequestID to get the completion factor of. + +Returns: +-------- + A factor (between 0 and 1) indicating how much of the request has + been completed.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetCurrentDownloadError = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetCurrentUploadError = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetProjectedVolumeSubsetBufferSize = +R"doc(Compute the buffer size (in bytes) for a projected volume subset +request. + +Parameters: +----------- + +minVoxelCoordinates : + The minimum voxel coordinates to request in each dimension + (inclusive). + +maxVoxelCoordinates : + The maximum voxel coordinates to request in each dimension + (exclusive). + +projectedDimensions : + The 2D dimension group that the plane in the source dimensiongroup + is projected into. It must be a 2D subset of the source + dimensions. + +format : + Voxel format of the destination buffer. + +LOD : + The LOD level the requested data is read from. + +channel : + The channel index the requested data is read from. + +Returns: +-------- + The buffer size needed)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetVDSProduceStatus = +R"doc(Get the produce status for the specific DimensionsND/LOD/Channel +combination. + +Parameters: +----------- + +dimensionsND : + The dimensions group we're getting the produce status for. + +LOD : + The LOD level we're getting the produce status for. + +channel : + The channel index we're getting the produce status for. + +Returns: +-------- + The produce status for the specific DimensionsND/LOD/Channel + combination.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetVolumeDataLayout = +R"doc(Get the VolumeDataLayout object for a VDS. + +Returns: +-------- + The VolumeDataLayout object associated with the VDS or NULL if + there is no valid VolumeDataLayout.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetVolumeSamplesBufferSize = +R"doc(Compute the buffer size (in bytes) for a volume samples request. + +Parameters: +----------- + +sampleCount : + Number of samples to request. + +channel : + The channel index the requested data is read from. + +Returns: +-------- + The buffer size needed)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetVolumeSubsetBufferSize = +R"doc(Compute the buffer size (in bytes) for a volume subset request. + +Parameters: +----------- + +minVoxelCoordinates : + The minimum voxel coordinates to request in each dimension + (inclusive). + +maxVoxelCoordinates : + The maximum voxel coordinates to request in each dimension + (exclusive). + +format : + Voxel format of the destination buffer. + +LOD : + The LOD level the requested data is read from. + +channel : + The channel index the requested data is read from. + +Returns: +-------- + The buffer size needed)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_GetVolumeTracesBufferSize = +R"doc(Compute the buffer size (in bytes) for a volume traces request. + +Parameters: +----------- + +traceCount : + Number of traces to request. + +traceDimension : + The dimension to trace + +LOD : + The LOD level the requested data is read from. + +channel : + The channel index the requested data is read from. + +Returns: +-------- + The buffer size needed)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_IVolumeDataAccessManager = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_IsCanceled = +R"doc(Check if a request was canceled (e.g. the VDS was invalidated before +the request was processed). If the request was canceled, the buffer +does not contain valid data. + +Parameters: +----------- + +requestID : + The RequestID to check for cancellation. + +Returns: +-------- + Either IsCompleted, IsCanceled or WaitForCompletion will return + True a single time, after that the request is taken out of the + system.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_IsCompleted = +R"doc(Check if a request completed successfully. If the request completed, +the buffer now contains valid data. + +Parameters: +----------- + +requestID : + The RequestID to check for completion. + +Returns: +-------- + Either IsCompleted, IsCanceled or WaitForCompletion will return + True a single time, after that the request is taken out of the + system.)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_PrefetchVolumeChunk = +R"doc(Force production of a specific volume data chunk + +Parameters: +----------- + +dimensionsND : + The dimensiongroup the requested chunk belongs to. + +LOD : + The LOD level the requested chunk belongs to. + +channel : + The channel index the requested chunk belongs to. + +chunkIndex : + The index of the chunk to prefetch. + +Returns: +-------- + The RequestID which can be used to query the status of the + request, cancel the request or wait for the request to complete)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_RefCount = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_Release = R"doc()doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_RequestProjectedVolumeSubset = +R"doc(Request a subset projected from an arbitrary 3D plane through the +subset onto one of the sides of the subset. + +Parameters: +----------- + +buffer : + Pointer to a preallocated buffer holding at least as many elements + of format as indicated by minVoxelCoordinates and + maxVoxelCoordinates for the projected dimensions. + +bufferByteSize : + The size of the provided buffer, in bytes. + +dimensionsND : + The dimensiongroup the requested data is read from. + +LOD : + The LOD level the requested data is read from. + +channel : + The channel index the requested data is read from. + +minVoxelCoordinates : + The minimum voxel coordinates to request in each dimension + (inclusive). + +maxVoxelCoordinates : + The maximum voxel coordinates to request in each dimension + (exclusive). + +voxelPlane : + The plane equation for the projection from the dimension source to + the projected dimensions (which must be a 2D subset of the source + dimensions). + +projectedDimensions : + The 2D dimension group that the plane in the source dimensiongroup + is projected into. It must be a 2D subset of the source + dimensions. + +interpolationMethod : + Interpolation method to use when sampling the buffer. + +format : + Voxel format of the destination buffer. + +replacementNoValue : + If specified, this value is used to replace regions of the input + VDS that has no data. + +Returns: +-------- + The RequestID which can be used to query the status of the + request, cancel the request or wait for the request to complete)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_RequestVolumeSamples = +R"doc(Request sampling of the input VDS at the specified coordinates. + +Parameters: +----------- + +buffer : + Pointer to a preallocated buffer holding at least sampleCount + elements. + +bufferByteSize : + The size of the provided buffer, in bytes. + +dimensionsND : + The dimensiongroup the requested data is read from. + +LOD : + The LOD level the requested data is read from. + +channel : + The channel index the requested data is read from. + +samplePositions : + Pointer to array of VolumeDataLayout::Dimensionality_Max-elements + indicating the positions to sample. May be deleted once + RequestVolumeSamples return, as HueSpace makes a deep copy of the + data. + +sampleCount : + Number of samples to request. + +interpolationMethod : + Interpolation method to use when sampling the buffer. + +replacementNoValue : + If specified, this value is used to replace regions of the input + VDS that has no data. + +Returns: +-------- + The RequestID which can be used to query the status of the + request, cancel the request or wait for the request to complete)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_RequestVolumeSubset = +R"doc(Request a subset of the input VDS. + +Parameters: +----------- + +buffer : + Pointer to a preallocated buffer holding at least as many elements + of format as indicated by minVoxelCoordinates and + maxVoxelCoordinates. + +bufferByteSize : + The size of the provided buffer, in bytes. + +dimensionsND : + The dimensiongroup the requested data is read from. + +LOD : + The LOD level the requested data is read from. + +channel : + The channel index the requested data is read from. + +minVoxelCoordinates : + The minimum voxel coordinates to request in each dimension + (inclusive). + +maxVoxelCoordinates : + The maximum voxel coordinates to request in each dimension + (exclusive). + +format : + Voxel format of the destination buffer. + +replacementNoValue : + If specified, this value is used to replace regions of the input + VDS that has no data. + +Returns: +-------- + The RequestID which can be used to query the status of the + request, cancel the request or wait for the request to complete)doc"; + +static const char *__doc_OpenVDS_IVolumeDataAccessManager_RequestVolumeTraces = +R"doc(Request traces from the input VDS. + +Parameters: +----------- + +buffer : + Pointer to a preallocated buffer holding at least traceCount * + number of samples in the traceDimension. + +bufferByteSize : + The size of the provided buffer, in bytes. + +dimensionsND : + The dimensiongroup the requested data is read from. + +LOD : + The LOD level the requested data is read from. + +channel : + The channel index the requested data is read from. + +tracePositions : + Pointer to array of traceCount + VolumeDataLayout::Dimensionality_Max-elements indicating the trace + positions. + +traceCount : + Number of traces to request. + +interpolationMethod : + Interpolation method to use when sampling the buffer. + +traceDimension : + The dimension to trace + +replacementNoValue : + If specified, this value is used to replace regions of the input + VDS that has no data. -static const char *__doc_OpenVDS_GoogleOpenOptions_CredentialsType_SignedUrlPath = R"doc()doc"; +Returns: +-------- + The RequestID which can be used to query the status of the + request, cancel the request or wait for the request to complete)doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessManager_UploadErrorCount = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_2 = -R"doc(GoogleOpenOptions constructor +static const char *__doc_OpenVDS_IVolumeDataAccessManager_WaitForCompletion = +R"doc(Wait for a request to complete successfully. If the request completed, +the buffer now contains valid data. Parameters: ----------- -bucket : - The bucket of the VDS - -pathPrefix : - The prefix of the VDS +requestID : + The RequestID to wait for completion of. -credentials : - Google Cloud Storage access credentials)doc"; +millisecondsBeforeTimeout : + The number of milliseconds to wait before timing out (optional). A + value of 0 indicates there is no timeout and we will wait for + however long it takes. Note that the request is not automatically + canceled if the wait times out, you can also use this mechanism to + e.g. update a progress bar while waiting. If you want to cancel + the request you have to explicitly call CancelRequest() and then + wait for the request to stop writing to the buffer. -static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_3 = R"doc()doc"; +Returns: +-------- + Either IsCompleted, IsCanceled or WaitForCompletion will return + True a single time, after that the request is taken out of the + system. Whenever WaitForCompletion returns False you need to call + IsCanceled() to know if that was because of a timeout or if the + request was canceled.)doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_4 = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_5 = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessorWithRegions = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_6 = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessorWithRegions_CurrentRegion = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_7 = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_GetLayout = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_GoogleOpenOptions_8 = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_GetManager = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_SetSignedUrl = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_IVolumeDataAccessor = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_bucket = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_IndexOutOfRangeException = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_credentials = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_Manager = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_credentialsType = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_Manager_CloneVolumeDataAccessor = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_pathPrefix = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_Manager_DestroyVolumeDataAccessor = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_region = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_Manager_Manager = R"doc()doc"; -static const char *__doc_OpenVDS_GoogleOpenOptions_storageClass = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_ReadErrorException = R"doc()doc"; -static const char *__doc_OpenVDS_HttpOpenOptions = -R"doc(Options for opening a VDS with a plain http url. If there are query -parameters in then they will be appended to the different sub urls. -The resulting IO backend will not support uploading data.)doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_ReadErrorException_errorCode = R"doc()doc"; -static const char *__doc_OpenVDS_HttpOpenOptions_HttpOpenOptions = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataAccessor_ReadErrorException_message = R"doc()doc"; -static const char *__doc_OpenVDS_HttpOpenOptions_HttpOpenOptions_2 = -R"doc(HttpOpenOptions constructor +static const char *__doc_OpenVDS_IVolumeDataReadAccessor = R"doc()doc"; -Parameters: ------------ +static const char *__doc_OpenVDS_IVolumeDataReadAccessor_2 = R"doc()doc"; -url : - The http base url of the VDS)doc"; +static const char *__doc_OpenVDS_IVolumeDataReadAccessor_GetValue = R"doc()doc"; -static const char *__doc_OpenVDS_HttpOpenOptions_url = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataReadWriteAccessor = R"doc()doc"; -static const char *__doc_OpenVDS_IJKGridDefinition = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataReadWriteAccessor_2 = R"doc()doc"; -static const char *__doc_OpenVDS_IJKGridDefinition_IJKGridDefinition = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataReadWriteAccessor_Cancel = R"doc()doc"; -static const char *__doc_OpenVDS_IJKGridDefinition_IJKGridDefinition_2 = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataReadWriteAccessor_Commit = R"doc()doc"; -static const char *__doc_OpenVDS_IJKGridDefinition_iUnitStep = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataReadWriteAccessor_SetValue = R"doc()doc"; -static const char *__doc_OpenVDS_IJKGridDefinition_jUnitStep = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataRegions = R"doc()doc"; -static const char *__doc_OpenVDS_IJKGridDefinition_kUnitStep = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataRegions_Region = R"doc()doc"; -static const char *__doc_OpenVDS_IJKGridDefinition_origin = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataRegions_RegionCount = R"doc()doc"; -static const char *__doc_OpenVDS_IOManager = R"doc()doc"; +static const char *__doc_OpenVDS_IVolumeDataRegions_RegionFromIndex = R"doc()doc"; static const char *__doc_OpenVDS_InMemoryOpenOptions = R"doc(Options for opening a VDS which is stored in memory (for testing))doc"; @@ -861,6 +1666,26 @@ static const char *__doc_OpenVDS_InterpolationMethod_Nearest = R"doc(< Snap to t static const char *__doc_OpenVDS_InterpolationMethod_Triangular = R"doc(< Triangular interpolation used to interpolate heightmap data)doc"; +static const char *__doc_OpenVDS_InvalidArgument = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidArgument_GetErrorMessage = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidArgument_GetParameterName = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidArgument_InvalidArgument = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidArgument_m_errorMessage = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidArgument_m_parameterName = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidOperation = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidOperation_GetErrorMessage = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidOperation_InvalidOperation = R"doc()doc"; + +static const char *__doc_OpenVDS_InvalidOperation_m_errorMessage = R"doc()doc"; + static const char *__doc_OpenVDS_KnownAxisNames = R"doc()doc"; static const char *__doc_OpenVDS_KnownAxisNames_Crossline = @@ -1063,6 +1888,18 @@ static const char *__doc_OpenVDS_M4 = R"doc()doc"; static const char *__doc_OpenVDS_M4_data = R"doc()doc"; +static const char *__doc_OpenVDS_MessageBufferException = R"doc()doc"; + +static const char *__doc_OpenVDS_MessageBufferException_AddToBuffer = R"doc()doc"; + +static const char *__doc_OpenVDS_MessageBufferException_MESSAGE_BUFFER_SIZE = R"doc()doc"; + +static const char *__doc_OpenVDS_MessageBufferException_MessageBufferException = R"doc()doc"; + +static const char *__doc_OpenVDS_MessageBufferException_m_messageBuffer = R"doc()doc"; + +static const char *__doc_OpenVDS_MessageBufferException_m_usedSize = R"doc()doc"; + static const char *__doc_OpenVDS_MetadataContainer = R"doc()doc"; static const char *__doc_OpenVDS_MetadataContainer_ClearMetadata = R"doc()doc"; @@ -1593,6 +2430,18 @@ Returns: static const char *__doc_OpenVDS_ReadElement_2 = R"doc()doc"; +static const char *__doc_OpenVDS_RequestFormat = R"doc()doc"; + +static const char *__doc_OpenVDS_RequestFormat_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_RequestFormat_3 = R"doc()doc"; + +static const char *__doc_OpenVDS_RequestFormat_4 = R"doc()doc"; + +static const char *__doc_OpenVDS_RequestFormat_5 = R"doc()doc"; + +static const char *__doc_OpenVDS_RequestFormat_6 = R"doc()doc"; + static const char *__doc_OpenVDS_ResultConverter = R"doc()doc"; static const char *__doc_OpenVDS_ResultConverter_ConvertValueT = R"doc()doc"; @@ -1611,8 +2460,6 @@ static const char *__doc_OpenVDS_StringWrapper_size = R"doc()doc"; static const char *__doc_OpenVDS_VDS = R"doc()doc"; -static const char *__doc_OpenVDS_VDS_2 = R"doc()doc"; - static const char *__doc_OpenVDS_VDSCoordinateTransformerBase = R"doc()doc"; static const char *__doc_OpenVDS_VDSCoordinateTransformerBase_SetGridDefinition = @@ -1716,8 +2563,6 @@ static const char *__doc_OpenVDS_VolumeDataAccessManager = R"doc()doc"; static const char *__doc_OpenVDS_VolumeDataAccessManager_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_3 = R"doc()doc"; - static const char *__doc_OpenVDS_VolumeDataAccessManager_AccessMode = R"doc()doc"; static const char *__doc_OpenVDS_VolumeDataAccessManager_AccessMode_AccessMode_Create = R"doc()doc"; @@ -1726,80 +2571,203 @@ static const char *__doc_OpenVDS_VolumeDataAccessManager_AccessMode_AccessMode_R static const char *__doc_OpenVDS_VolumeDataAccessManager_AccessMode_AccessMode_ReadWrite = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Cancel = -R"doc(Try to cancel the request. You still have to call -WaitForCompletion/IsCanceled to make sure the buffer is not being -written to and to take the job out of the system. It is possible that -the request has completed concurrently with the call to Cancel in -which case WaitForCompletion will return True. +static const char *__doc_OpenVDS_VolumeDataAccessManager_ClearUploadErrors = R"doc()doc"; -Parameters: ------------ +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateInterpolatingVolumeDataAccessor = R"doc()doc"; -requestID : - The requestID to cancel.)doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateInterpolatingVolumeDataAccessor_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_ClearUploadErrors = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DInterpolatingAccessorR32 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_CloneVolumeDataAccessor = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DInterpolatingAccessorR32_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DInterpolatingVolumeDataAccessorR32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DInterpolatingAccessorR64 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DInterpolatingVolumeDataAccessorR64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DInterpolatingAccessorR64_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DVolumeDataAccessor1Bit = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessor1Bit = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DVolumeDataAccessorR32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessor1Bit_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DVolumeDataAccessorR64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorR32 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DVolumeDataAccessorU16 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorR32_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DVolumeDataAccessorU32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorR64 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DVolumeDataAccessorU64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorR64_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create2DVolumeDataAccessorU8 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorU16 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DInterpolatingVolumeDataAccessorR32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorU16_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DInterpolatingVolumeDataAccessorR64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorU32 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DVolumeDataAccessor1Bit = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorU32_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DVolumeDataAccessorR32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorU64 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DVolumeDataAccessorR64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorU64_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DVolumeDataAccessorU16 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorU8 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DVolumeDataAccessorU32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadAccessorU8_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DVolumeDataAccessorU64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessor1Bit = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create3DVolumeDataAccessorU8 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessor1Bit_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DInterpolatingVolumeDataAccessorR32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorR32 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DInterpolatingVolumeDataAccessorR64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorR32_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DVolumeDataAccessor1Bit = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorR64 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DVolumeDataAccessorR32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorR64_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DVolumeDataAccessorR64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorU16 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DVolumeDataAccessorU16 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorU16_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DVolumeDataAccessorU32 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorU32 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DVolumeDataAccessorU64 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorU32_2 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_Create4DVolumeDataAccessorU8 = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorU64 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateInterpolatingVolumeDataAccessor = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorU64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorU8 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData2DReadWriteAccessorU8_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DInterpolatingAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DInterpolatingAccessorR32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DInterpolatingAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DInterpolatingAccessorR64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessor1Bit = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessor1Bit_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorR32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorR64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorU16 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorU16_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorU32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorU32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorU64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorU64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorU8 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadAccessorU8_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessor1Bit = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessor1Bit_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorR32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorR64 = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeDataAccessor = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorR64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorU16 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorU16_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorU32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorU32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorU64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorU64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorU8 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData3DReadWriteAccessorU8_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DInterpolatingAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DInterpolatingAccessorR32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DInterpolatingAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DInterpolatingAccessorR64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessor1Bit = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessor1Bit_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorR32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorR64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorU16 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorU16_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorU32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorU32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorU64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorU64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorU8 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadAccessorU8_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessor1Bit = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessor1Bit_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorR32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorR32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorR64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorR64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorU16 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorU16_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorU32 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorU32_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorU64 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorU64_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorU8 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeData4DReadWriteAccessorU8_2 = R"doc()doc"; static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeDataPageAccessor = R"doc(Create a volume data page accessor object for the VDS associated with @@ -1808,15 +2776,11 @@ the given VolumeDataLayout object. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the VDS that the - volume data page accessor will access. - dimensionsND : The dimensions group that the volume data page accessor will access. -lod : +LOD : The LOD level that the volume data page accessor will access. channel : @@ -1844,7 +2808,13 @@ Returns: A VolumeDataPageAccessor object for the VDS associated with the given VolumeDataLayout object.)doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_DestroyVolumeDataAccessor = R"doc()doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeDataReadAccessor = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeDataReadAccessor_2 = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeDataReadWriteAccessor = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_CreateVolumeDataReadWriteAccessor_2 = R"doc()doc"; static const char *__doc_OpenVDS_VolumeDataAccessManager_DestroyVolumeDataPageAccessor = R"doc(Destroy a volume data page accessor object. @@ -1852,9 +2822,21 @@ R"doc(Destroy a volume data page accessor object. Parameters: ----------- -pVolumeDataPageAccessor : +volumeDataPageAccessor : The VolumeDataPageAccessor object to destroy.)doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_Dispose = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_DoRequestProjectedVolumeSubset = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_DoRequestVolumeSamples = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_DoRequestVolumeSubset = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_DoRequestVolumeTraces = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_EnsureValid = R"doc()doc"; + static const char *__doc_OpenVDS_VolumeDataAccessManager_FlushUploadQueue = R"doc(Flush any pending writes and write updated layer status @@ -1867,20 +2849,6 @@ writeUpdatedLayerStatus : static const char *__doc_OpenVDS_VolumeDataAccessManager_ForceClearAllUploadErrors = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_GetCompletionFactor = -R"doc(Get the completion factor (between 0 and 1) of the request. - -Parameters: ------------ - -requestID : - The requestID to get the completion factor of. - -Returns: --------- - A factor (between 0 and 1) indicating how much of the request has - been completed.)doc"; - static const char *__doc_OpenVDS_VolumeDataAccessManager_GetCurrentDownloadError = R"doc()doc"; static const char *__doc_OpenVDS_VolumeDataAccessManager_GetCurrentUploadError = R"doc()doc"; @@ -1892,9 +2860,6 @@ request. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. - minVoxelCoordinates : The minimum voxel coordinates to request in each dimension (inclusive). @@ -1911,7 +2876,7 @@ projectedDimensions : format : Voxel format of the destination buffer. -lod : +LOD : The LOD level the requested data is read from. channel : @@ -1921,6 +2886,8 @@ Returns: -------- The buffer size needed)doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_GetProjectedVolumeSubsetBufferSize_2 = R"doc()doc"; + static const char *__doc_OpenVDS_VolumeDataAccessManager_GetVDSProduceStatus = R"doc(Get the produce status for the specific DimensionsND/LOD/Channel combination. @@ -1928,14 +2895,10 @@ combination. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the VDS that we're - getting the produce status for. - dimensionsND : The dimensions group we're getting the produce status for. -lod : +LOD : The LOD level we're getting the produce status for. channel : @@ -1960,9 +2923,6 @@ R"doc(Compute the buffer size (in bytes) for a volume samples request. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. - sampleCount : Number of samples to request. @@ -1979,9 +2939,6 @@ R"doc(Compute the buffer size (in bytes) for a volume subset request. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. - minVoxelCoordinates : The minimum voxel coordinates to request in each dimension (inclusive). @@ -1993,7 +2950,7 @@ maxVoxelCoordinates : format : Voxel format of the destination buffer. -lod : +LOD : The LOD level the requested data is read from. channel : @@ -2003,22 +2960,21 @@ Returns: -------- The buffer size needed)doc"; +static const char *__doc_OpenVDS_VolumeDataAccessManager_GetVolumeSubsetBufferSize_2 = R"doc()doc"; + static const char *__doc_OpenVDS_VolumeDataAccessManager_GetVolumeTracesBufferSize = R"doc(Compute the buffer size (in bytes) for a volume traces request. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. - traceCount : Number of traces to request. traceDimension : The dimension to trace -lod : +LOD : The LOD level the requested data is read from. channel : @@ -2028,84 +2984,99 @@ Returns: -------- The buffer size needed)doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_IsCanceled = -R"doc(Check if a request was canceled (e.g. the VDS was invalidated before -the request was processed). If the request was canceled, the buffer -does not contain valid data. +static const char *__doc_OpenVDS_VolumeDataAccessManager_IsValid = R"doc()doc"; + +static const char *__doc_OpenVDS_VolumeDataAccessManager_PrefetchVolumeChunk = +R"doc(Force production of a specific volume data chunk Parameters: ----------- -requestID : - The requestID to check for cancellation. - -Returns: --------- - Either IsCompleted, IsCanceled or WaitForCompletion will return - True a single time, after that the request is taken out of the - system.)doc"; +dimensionsND : + The dimensiongroup the requested chunk belongs to. -static const char *__doc_OpenVDS_VolumeDataAccessManager_IsCompleted = -R"doc(Check if a request completed successfully. If the request completed, -the buffer now contains valid data. +LOD : + The LOD level the requested chunk belongs to. -Parameters: ------------ +channel : + The channel index the requested chunk belongs to. -requestID : - The requestID to check for completion. +chunkIndex : + The index of the chunk to prefetch. Returns: -------- - Either IsCompleted, IsCanceled or WaitForCompletion will return - True a single time, after that the request is taken out of the - system.)doc"; + A VolumeDataRequest instance encapsulating the request status.)doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_PrefetchVolumeChunk = -R"doc(Force production of a specific volume data chunk +static const char *__doc_OpenVDS_VolumeDataAccessManager_RequestProjectedVolumeSubset = +R"doc(Request a subset projected from an arbitrary 3D plane through the +subset onto one of the sides of the subset. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. +buffer : + Pointer to a preallocated buffer holding at least as many elements + of format as indicated by minVoxelCoordinates and + maxVoxelCoordinates for the projected dimensions. + +bufferByteSize : + The size of the provided buffer, in bytes. dimensionsND : - The dimensiongroup the requested chunk belongs to. + The dimensiongroup the requested data is read from. + +LOD : + The LOD level the requested data is read from. + +channel : + The channel index the requested data is read from. + +minVoxelCoordinates : + The minimum voxel coordinates to request in each dimension + (inclusive). + +maxVoxelCoordinates : + The maximum voxel coordinates to request in each dimension + (exclusive). + +voxelPlane : + The plane equation for the projection from the dimension source to + the projected dimensions (which must be a 2D subset of the source + dimensions). + +projectedDimensions : + The 2D dimension group that the plane in the source dimensiongroup + is projected into. It must be a 2D subset of the source + dimensions. -lod : - The LOD level the requested chunk belongs to. +interpolationMethod : + Interpolation method to use when sampling the buffer. -channel : - The channel index the requested chunk belongs to. +format : + Voxel format of the destination buffer. -chunk : - The index of the chunk to prefetch. +replacementNoValue : + If specified, this value is used to replace regions of the input + VDS that has no data. Returns: -------- - The requestID which can be used to query the status of the - request, cancel the request or wait for the request to complete)doc"; + A VolumeDataRequest instance encapsulating the request status and + buffer.)doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_RequestProjectedVolumeSubset = +static const char *__doc_OpenVDS_VolumeDataAccessManager_RequestProjectedVolumeSubset_2 = R"doc(Request a subset projected from an arbitrary 3D plane through the -subset onto one of the sides of the subset. +subset onto one of the sides of the subset, using an automatically +allocated buffer. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. - -buffer : - Pointer to a preallocated buffer holding at least as many elements - of format as indicated by minVoxelCoordinates and - maxVoxelCoordinates for the projected dimensions. - dimensionsND : The dimensiongroup the requested data is read from. -lod : +LOD : The LOD level the requested data is read from. channel : @@ -2129,36 +3100,33 @@ projectedDimensions : is projected into. It must be a 2D subset of the source dimensions. +format : + Voxel format of the destination buffer. + interpolationMethod : Interpolation method to use when sampling the buffer. -format : - Voxel format of the destination buffer. +replacementNoValue : + If specified, this value is used to replace regions of the input + VDS that has no data. Returns: -------- - The requestID which can be used to query the status of the - request, cancel the request or wait for the request to complete)doc"; + A VolumeDataRequest instance encapsulating the request status and + buffer.)doc"; -static const char *__doc_OpenVDS_VolumeDataAccessManager_RequestProjectedVolumeSubset_2 = +static const char *__doc_OpenVDS_VolumeDataAccessManager_RequestProjectedVolumeSubset_3 = R"doc(Request a subset projected from an arbitrary 3D plane through the -subset onto one of the sides of the subset. +subset onto one of the sides of the subset, using an automatically +allocated typed buffer. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. - -buffer : - Pointer to a preallocated buffer holding at least as many elements - of format as indicated by minVoxelCoordinates and - maxVoxelCoordinates for the projected dimensions. - dimensionsND : The dimensiongroup the requested data is read from. -lod : +LOD : The LOD level the requested data is read from. channel : @@ -2185,16 +3153,14 @@ projectedDimensions : interpolationMethod : Interpolation method to use when sampling the buffer. -format : - Voxel format of the destination buffer. - replacementNoValue : - Value used to replace region of the input VDS that has no data. + If specified, this value is used to replace regions of the input + VDS that has no data. Returns: -------- - The requestID which can be used to query the status of the - request, cancel the request or wait for the request to complete)doc"; + A VolumeDataRequest instance encapsulating the request status and + buffer.)doc"; static const char *__doc_OpenVDS_VolumeDataAccessManager_RequestVolumeSamples = R"doc(Request sampling of the input VDS at the specified coordinates. @@ -2202,26 +3168,27 @@ R"doc(Request sampling of the input VDS at the specified coordinates. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. - buffer : Pointer to a preallocated buffer holding at least sampleCount elements. +bufferByteSize : + The size of the provided buffer, in bytes. + dimensionsND : The dimensiongroup the requested data is read from. -lod : +LOD : The LOD level the requested data is read from. channel : The channel index the requested data is read from. samplePositions : - Pointer to array of Dimensionality_Max-elements indicating the - positions to sample. May be deleted once requestVolumeSamples - return, as OpenVDS makes a deep copy of the data. + Pointer to array of VolumeDataLayout::Dimensionality_Max-elements + indicating the positions to sample. May be deleted once + RequestVolumeSamples return, as HueSpace makes a deep copy of the + data. sampleCount : Number of samples to request. @@ -2229,37 +3196,36 @@ sampleCount : interpolationMethod : Interpolation method to use when sampling the buffer. +replacementNoValue : + If specified, this value is used to replace regions of the input + VDS that has no data. + Returns: -------- - The requestID which can be used to query the status of the - request, cancel the request or wait for the request to complete)doc"; + A VolumeDataRequest instance encapsulating the request status and + buffer.)doc"; static const char *__doc_OpenVDS_VolumeDataAccessManager_RequestVolumeSamples_2 = -R"doc(Request sampling of the input VDS at the specified coordinates. +R"doc(Request sampling of the input VDS at the specified coordinates, using +an automatically allocated buffer. Parameters: ----------- -volumeDataLayout : - The VolumeDataLayout object associated with the input VDS. - -buffer : - Pointer to a preallocated buffer holding at least sampleCount - elements. - dimensionsND : The dimensiongroup the requested data is read from. -lod : +LOD : The LOD level the requested data is read from. channel : The channel index the requested data is read from. samplePositions : - Pointer to array of Dimensionality_Max-elements indicating the - positions to sample. May be deleted once requestVolumeSamples - return, as OpenVDS makes a deep copy of the data. + Pointer to array of VolumeDataLayout::Dimensionality_Max-elements + indicating the positions to sample. May be deleted once + RequestVolumeSamples return, as HueSpace makes a deep copy of the + data. sampleCount : Number of samples to request. @@ -2268,12 +3234,13 @@ interpolationMethod : Interpolation method to use when sampling the buffer. replacementNoValue : - Value used to replace region of the input VDS that has no data. + If specified, this value is used to replace regions of the input + VDS that has no data. Returns: -------- - The requestID which can be used to query the status of the - request, cancel the request or wait for the request to complete)doc"; + A VolumeDataRequest instance encapsulating the request status and + buffer.)doc"; static const char *__doc_OpenVDS_VolumeDataAccessManager_RequestVolumeSubset = R"doc(Request a subset of the input VDS. @@ -2286,13 +3253,13 @@ buffer : of format as indicated by minVoxelCoordinates and maxVoxelCoordinates. -volumeDataLayout : - The VolumeDataLayout object associated with the