Commit c863c036 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Merge branch feature/stein.pedersen/python-api with refs/heads/master into...

Merge branch feature/stein.pedersen/python-api with refs/heads/master into refs/merge-requests/24/train
parents 17ca4800 ff7c0e21
Pipeline #591 passed with stages
in 7 minutes and 38 seconds
......@@ -39,6 +39,8 @@ set_target_properties(core
SET(pythonsources
${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
${CMAKE_CURRENT_SOURCE_DIR}/api.py
${CMAKE_CURRENT_SOURCE_DIR}/volumedataaccess.py
)
add_custom_command(TARGET core
......
......@@ -64,15 +64,28 @@ PyGlobal::initModule(py::module& m)
Error_.def_readwrite("code" , &Error::code , OPENVDS_DOCSTRING(Error_code));
Error_.def_readwrite("string" , &Error::string , OPENVDS_DOCSTRING(Error_string));
m.def("open" , static_cast<native::VDSHandle(*)(const native::OpenOptions &, native::Error &)>(&Open), OPENVDS_DOCSTRING(Open));
m.def("open" , static_cast<native::VDSHandle(*)(native::IOManager *, native::Error &)>(&Open), OPENVDS_DOCSTRING(Open_2));
m.def("create" , static_cast<native::VDSHandle(*)(const native::OpenOptions &, const native::VolumeDataLayoutDescriptor &, VectorWrapper<native::VolumeDataAxisDescriptor>, VectorWrapper<native::VolumeDataChannelDescriptor>, const native::MetadataReadAccess &, native::Error &)>(&Create), OPENVDS_DOCSTRING(Create));
m.def("create" , static_cast<native::VDSHandle(*)(native::IOManager *, const native::VolumeDataLayoutDescriptor &, VectorWrapper<native::VolumeDataAxisDescriptor>, VectorWrapper<native::VolumeDataChannelDescriptor>, const native::MetadataReadAccess &, native::Error &)>(&Create), OPENVDS_DOCSTRING(Create_2));
m.def("getLayout" , static_cast<native::VolumeDataLayout *(*)(native::VDSHandle)>(&GetLayout), OPENVDS_DOCSTRING(GetLayout));
m.def("getAccessManager" , static_cast<native::VolumeDataAccessManager *(*)(native::VDSHandle)>(&GetAccessManager), OPENVDS_DOCSTRING(GetAccessManager));
m.def("close" , static_cast<void(*)(native::VDSHandle)>(&Close), OPENVDS_DOCSTRING(Close));
m.def("open" , static_cast<native::VDSHandle(*)(const native::OpenOptions &, native::Error &)>(&Open), py::arg("options"), py::arg("error"), OPENVDS_DOCSTRING(Open));
m.def("open" , static_cast<native::VDSHandle(*)(native::IOManager *, native::Error &)>(&Open), py::arg("ioManager"), py::arg("error"), OPENVDS_DOCSTRING(Open_2));
m.def("create" , static_cast<native::VDSHandle(*)(const native::OpenOptions &, const native::VolumeDataLayoutDescriptor &, VectorWrapper<native::VolumeDataAxisDescriptor>, VectorWrapper<native::VolumeDataChannelDescriptor>, const native::MetadataReadAccess &, native::Error &)>(&Create), py::arg("options"), py::arg("layoutDescriptor"), py::arg("axisDescriptors"), py::arg("channelDescriptors"), py::arg("metadata"), py::arg("error"), OPENVDS_DOCSTRING(Create));
m.def("create" , static_cast<native::VDSHandle(*)(native::IOManager *, const native::VolumeDataLayoutDescriptor &, VectorWrapper<native::VolumeDataAxisDescriptor>, VectorWrapper<native::VolumeDataChannelDescriptor>, const native::MetadataReadAccess &, native::Error &)>(&Create), py::arg("ioManager"), py::arg("layoutDescriptor"), py::arg("axisDescriptors"), py::arg("channelDescriptors"), py::arg("metadata"), py::arg("error"), OPENVDS_DOCSTRING(Create_2));
m.def("getLayout" , static_cast<native::VolumeDataLayout *(*)(native::VDSHandle)>(&GetLayout), py::arg("handle"), OPENVDS_DOCSTRING(GetLayout));
m.def("getAccessManager" , static_cast<native::VolumeDataAccessManager *(*)(native::VDSHandle)>(&GetAccessManager), py::arg("handle"), OPENVDS_DOCSTRING(GetAccessManager));
m.def("close" , static_cast<void(*)(native::VDSHandle)>(&Close), py::arg("handle"), OPENVDS_DOCSTRING(Close));
//AUTOGEN-END
Error_.def(py::init<>());
Error_.def("__repr__", [](native::Error const& self){ std::string tmp = std::to_string(self.code); return std::string("Error(code=") + tmp + ", string='" + self.string + "')"; });
OpenOptions_.def("__repr__", [](OpenOptions const& self)
{
std::string conn = "Unknown";
switch(self.connectionType)
{
case OpenOptions::ConnectionType::AWS : conn = std::string("AWS" ); break;
case OpenOptions::ConnectionType::Azure : conn = std::string("Azure" ); break;
case OpenOptions::ConnectionType::File : conn = std::string("File" ); break;
case OpenOptions::ConnectionType::InMemory: conn = std::string("InMemory"); break;
}
return std::string("OpenOptions(connectionType='" + conn + "')");
});
}
......@@ -33,6 +33,10 @@
namespace OpenVDS {
class VolumeDataAccessorBase
{
};
#ifdef OPENVDS_DEVELOPMENT_BUILD
struct VDS;
......
This diff is collapsed.
......@@ -108,7 +108,7 @@ PyVolumeData::initModule(py::module& m)
Dimensionality_.value("Dimensionality_6" , Dimensionality::Dimensionality_6 , OPENVDS_DOCSTRING(Dimensionality_Dimensionality_6));
Dimensionality_.value("Dimensionality_Max" , Dimensionality::Dimensionality_Max , OPENVDS_DOCSTRING(Dimensionality_Dimensionality_Max));
m.def("getLODSize" , static_cast<int(*)(int, int, int, bool)>(&GetLODSize), OPENVDS_DOCSTRING(GetLODSize));
m.def("getLODSize" , static_cast<int(*)(int, int, int, bool)>(&GetLODSize), py::arg("voxelMin"), py::arg("voxelMax"), py::arg("lod"), py::arg("includePartialUpperVoxel"), OPENVDS_DOCSTRING(GetLODSize));
//AUTOGEN-END
}
This diff is collapsed.
......@@ -35,8 +35,8 @@ PyVolumeDataAxisDescriptor::initModule(py::module& m)
VolumeDataAxisDescriptor_.def("getCoordinateMin" , static_cast<float(VolumeDataAxisDescriptor::*)() const>(&VolumeDataAxisDescriptor::GetCoordinateMin), OPENVDS_DOCSTRING(VolumeDataAxisDescriptor_GetCoordinateMin));
VolumeDataAxisDescriptor_.def("getCoordinateMax" , static_cast<float(VolumeDataAxisDescriptor::*)() const>(&VolumeDataAxisDescriptor::GetCoordinateMax), OPENVDS_DOCSTRING(VolumeDataAxisDescriptor_GetCoordinateMax));
VolumeDataAxisDescriptor_.def("getCoordinateStep" , static_cast<float(VolumeDataAxisDescriptor::*)() const>(&VolumeDataAxisDescriptor::GetCoordinateStep), OPENVDS_DOCSTRING(VolumeDataAxisDescriptor_GetCoordinateStep));
VolumeDataAxisDescriptor_.def("sampleIndexToCoordinate" , static_cast<float(VolumeDataAxisDescriptor::*)(int)>(&VolumeDataAxisDescriptor::SampleIndexToCoordinate), OPENVDS_DOCSTRING(VolumeDataAxisDescriptor_SampleIndexToCoordinate));
VolumeDataAxisDescriptor_.def("coordinateToSampleIndex" , static_cast<int(VolumeDataAxisDescriptor::*)(float)>(&VolumeDataAxisDescriptor::CoordinateToSampleIndex), OPENVDS_DOCSTRING(VolumeDataAxisDescriptor_CoordinateToSampleIndex));
VolumeDataAxisDescriptor_.def("sampleIndexToCoordinate" , static_cast<float(VolumeDataAxisDescriptor::*)(int)>(&VolumeDataAxisDescriptor::SampleIndexToCoordinate), py::arg("sampleIndex"), OPENVDS_DOCSTRING(VolumeDataAxisDescriptor_SampleIndexToCoordinate));
VolumeDataAxisDescriptor_.def("coordinateToSampleIndex" , static_cast<int(VolumeDataAxisDescriptor::*)(float)>(&VolumeDataAxisDescriptor::CoordinateToSampleIndex), py::arg("coordinate"), OPENVDS_DOCSTRING(VolumeDataAxisDescriptor_CoordinateToSampleIndex));
//AUTOGEN-END
}
......
......@@ -53,8 +53,8 @@ PyVolumeDataChannelDescriptor::initModule(py::module& m)
VolumeDataChannelDescriptor_.def("getNoValue" , static_cast<float(VolumeDataChannelDescriptor::*)() const>(&VolumeDataChannelDescriptor::GetNoValue), OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_GetNoValue));
VolumeDataChannelDescriptor_.def("getIntegerScale" , static_cast<float(VolumeDataChannelDescriptor::*)() const>(&VolumeDataChannelDescriptor::GetIntegerScale), OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_GetIntegerScale));
VolumeDataChannelDescriptor_.def("getIntegerOffset" , static_cast<float(VolumeDataChannelDescriptor::*)() const>(&VolumeDataChannelDescriptor::GetIntegerOffset), OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_GetIntegerOffset));
VolumeDataChannelDescriptor_.def_static("traceMappedVolumeDataChannelDescriptor", static_cast<native::VolumeDataChannelDescriptor(*)(native::VolumeDataChannelDescriptor::Format, native::VolumeDataChannelDescriptor::Components, const char *, const char *, float, float, int, VolumeDataChannelDescriptor::Flags)>(&VolumeDataChannelDescriptor::TraceMappedVolumeDataChannelDescriptor), OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_TraceMappedVolumeDataChannelDescriptor));
VolumeDataChannelDescriptor_.def_static("traceMappedVolumeDataChannelDescriptor", static_cast<native::VolumeDataChannelDescriptor(*)(native::VolumeDataChannelDescriptor::Format, native::VolumeDataChannelDescriptor::Components, const char *, const char *, float, float, int, VolumeDataChannelDescriptor::Flags, float)>(&VolumeDataChannelDescriptor::TraceMappedVolumeDataChannelDescriptor), OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_TraceMappedVolumeDataChannelDescriptor_2));
VolumeDataChannelDescriptor_.def_static("traceMappedVolumeDataChannelDescriptor", static_cast<native::VolumeDataChannelDescriptor(*)(native::VolumeDataChannelDescriptor::Format, native::VolumeDataChannelDescriptor::Components, const char *, const char *, float, float, int, VolumeDataChannelDescriptor::Flags)>(&VolumeDataChannelDescriptor::TraceMappedVolumeDataChannelDescriptor), py::arg("format"), py::arg("components"), py::arg("pName"), py::arg("pUnit"), py::arg("valueRangeMin"), py::arg("valueRangeMax"), py::arg("mappedValueCount"), py::arg("flags"), OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_TraceMappedVolumeDataChannelDescriptor));
VolumeDataChannelDescriptor_.def_static("traceMappedVolumeDataChannelDescriptor", static_cast<native::VolumeDataChannelDescriptor(*)(native::VolumeDataChannelDescriptor::Format, native::VolumeDataChannelDescriptor::Components, const char *, const char *, float, float, int, VolumeDataChannelDescriptor::Flags, float)>(&VolumeDataChannelDescriptor::TraceMappedVolumeDataChannelDescriptor), py::arg("format"), py::arg("components"), py::arg("pName"), py::arg("pUnit"), py::arg("valueRangeMin"), py::arg("valueRangeMax"), py::arg("mappedValueCount"), py::arg("flags"), py::arg("noValue"), OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_TraceMappedVolumeDataChannelDescriptor_2));
py::enum_<VolumeDataChannelDescriptor::Flags>
VolumeDataChannelDescriptor_Flags_(VolumeDataChannelDescriptor_,"Flags", OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_Flags));
......@@ -84,7 +84,7 @@ PyVolumeDataChannelDescriptor::initModule(py::module& m)
VolumeDataChannelDescriptor_Components_.value("Components_2" , VolumeDataChannelDescriptor::Components::Components_2, OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_Components_Components_2));
VolumeDataChannelDescriptor_Components_.value("Components_4" , VolumeDataChannelDescriptor::Components::Components_4, OPENVDS_DOCSTRING(VolumeDataChannelDescriptor_Components_Components_4));
m.def("operator_bor" , static_cast<VolumeDataChannelDescriptor::Flags(*)(VolumeDataChannelDescriptor::Flags, VolumeDataChannelDescriptor::Flags)>(&operator|), OPENVDS_DOCSTRING(operator_bor));
m.def("operator_bor" , static_cast<VolumeDataChannelDescriptor::Flags(*)(VolumeDataChannelDescriptor::Flags, VolumeDataChannelDescriptor::Flags)>(&operator|), py::arg("lhs"), py::arg("rhs"), OPENVDS_DOCSTRING(operator_bor));
//AUTOGEN-END
}
......@@ -30,32 +30,57 @@ PyVolumeDataLayout::initModule(py::module& m)
VolumeDataLayout_.def("getContentsHash" , static_cast<uint64_t(VolumeDataLayout::*)() const>(&VolumeDataLayout::GetContentsHash), OPENVDS_DOCSTRING(VolumeDataLayout_GetContentsHash));
VolumeDataLayout_.def("getDimensionality" , static_cast<int(VolumeDataLayout::*)() const>(&VolumeDataLayout::GetDimensionality), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionality));
VolumeDataLayout_.def("getChannelCount" , static_cast<int(VolumeDataLayout::*)() const>(&VolumeDataLayout::GetChannelCount), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelCount));
VolumeDataLayout_.def("isChannelAvailable" , static_cast<bool(VolumeDataLayout::*)(const char *) const>(&VolumeDataLayout::IsChannelAvailable), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelAvailable));
VolumeDataLayout_.def("getChannelIndex" , static_cast<int(VolumeDataLayout::*)(const char *) const>(&VolumeDataLayout::GetChannelIndex), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelIndex));
VolumeDataLayout_.def("isChannelAvailable" , static_cast<bool(VolumeDataLayout::*)(const char *) const>(&VolumeDataLayout::IsChannelAvailable), py::arg("channelName"), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelAvailable));
VolumeDataLayout_.def("getChannelIndex" , static_cast<int(VolumeDataLayout::*)(const char *) const>(&VolumeDataLayout::GetChannelIndex), py::arg("channelName"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelIndex));
VolumeDataLayout_.def("getLayoutDescriptor" , static_cast<native::VolumeDataLayoutDescriptor(VolumeDataLayout::*)() const>(&VolumeDataLayout::GetLayoutDescriptor), OPENVDS_DOCSTRING(VolumeDataLayout_GetLayoutDescriptor));
VolumeDataLayout_.def("getChannelDescriptor" , static_cast<native::VolumeDataChannelDescriptor(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelDescriptor), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelDescriptor));
VolumeDataLayout_.def("getAxisDescriptor" , static_cast<native::VolumeDataAxisDescriptor(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetAxisDescriptor), OPENVDS_DOCSTRING(VolumeDataLayout_GetAxisDescriptor));
VolumeDataLayout_.def("getChannelFormat" , static_cast<VolumeDataChannelDescriptor::Format(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelFormat), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelFormat));
VolumeDataLayout_.def("getChannelComponents" , static_cast<VolumeDataChannelDescriptor::Components(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelComponents), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelComponents));
VolumeDataLayout_.def("getChannelName" , static_cast<const char *(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelName), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelName));
VolumeDataLayout_.def("getChannelUnit" , static_cast<const char *(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelUnit), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelUnit));
VolumeDataLayout_.def("getChannelValueRangeMin" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelValueRangeMin), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelValueRangeMin));
VolumeDataLayout_.def("getChannelValueRangeMax" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelValueRangeMax), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelValueRangeMax));
VolumeDataLayout_.def("isChannelDiscrete" , static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelDiscrete), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelDiscrete));
VolumeDataLayout_.def("isChannelRenderable" , static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelRenderable), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelRenderable));
VolumeDataLayout_.def("isChannelAllowingLossyCompression", static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelAllowingLossyCompression), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelAllowingLossyCompression));
VolumeDataLayout_.def("isChannelUseZipForLosslessCompression", static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelUseZipForLosslessCompression), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelUseZipForLosslessCompression));
VolumeDataLayout_.def("getChannelMapping" , static_cast<native::VolumeDataMapping(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelMapping), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelMapping));
VolumeDataLayout_.def("getDimensionNumSamples" , static_cast<int(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionNumSamples), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionNumSamples));
VolumeDataLayout_.def("getDimensionName" , static_cast<const char *(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionName), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionName));
VolumeDataLayout_.def("getDimensionUnit" , static_cast<const char *(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionUnit), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionUnit));
VolumeDataLayout_.def("getDimensionMin" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionMin), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionMin));
VolumeDataLayout_.def("getDimensionMax" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionMax), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionMax));
VolumeDataLayout_.def("isChannelUseNoValue" , static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelUseNoValue), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelUseNoValue));
VolumeDataLayout_.def("getChannelNoValue" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelNoValue), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelNoValue));
VolumeDataLayout_.def("getChannelIntegerScale" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelIntegerScale), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelIntegerScale));
VolumeDataLayout_.def("getChannelIntegerOffset" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelIntegerOffset), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelIntegerOffset));
VolumeDataLayout_.def("getChannelDescriptor" , static_cast<native::VolumeDataChannelDescriptor(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelDescriptor), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelDescriptor));
VolumeDataLayout_.def("getAxisDescriptor" , static_cast<native::VolumeDataAxisDescriptor(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetAxisDescriptor), py::arg("dimension"), OPENVDS_DOCSTRING(VolumeDataLayout_GetAxisDescriptor));
VolumeDataLayout_.def("getChannelFormat" , static_cast<VolumeDataChannelDescriptor::Format(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelFormat), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelFormat));
VolumeDataLayout_.def("getChannelComponents" , static_cast<VolumeDataChannelDescriptor::Components(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelComponents), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelComponents));
VolumeDataLayout_.def("getChannelName" , static_cast<const char *(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelName), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelName));
VolumeDataLayout_.def("getChannelUnit" , static_cast<const char *(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelUnit), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelUnit));
VolumeDataLayout_.def("getChannelValueRangeMin" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelValueRangeMin), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelValueRangeMin));
VolumeDataLayout_.def("getChannelValueRangeMax" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelValueRangeMax), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelValueRangeMax));
VolumeDataLayout_.def("isChannelDiscrete" , static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelDiscrete), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelDiscrete));
VolumeDataLayout_.def("isChannelRenderable" , static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelRenderable), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelRenderable));
VolumeDataLayout_.def("isChannelAllowingLossyCompression", static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelAllowingLossyCompression), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelAllowingLossyCompression));
VolumeDataLayout_.def("isChannelUseZipForLosslessCompression", static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelUseZipForLosslessCompression), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelUseZipForLosslessCompression));
VolumeDataLayout_.def("getChannelMapping" , static_cast<native::VolumeDataMapping(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelMapping), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelMapping));
VolumeDataLayout_.def("getDimensionNumSamples" , static_cast<int(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionNumSamples), py::arg("dimension"), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionNumSamples));
VolumeDataLayout_.def("getDimensionName" , static_cast<const char *(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionName), py::arg("dimension"), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionName));
VolumeDataLayout_.def("getDimensionUnit" , static_cast<const char *(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionUnit), py::arg("dimension"), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionUnit));
VolumeDataLayout_.def("getDimensionMin" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionMin), py::arg("dimension"), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionMin));
VolumeDataLayout_.def("getDimensionMax" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetDimensionMax), py::arg("dimension"), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionMax));
VolumeDataLayout_.def("isChannelUseNoValue" , static_cast<bool(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::IsChannelUseNoValue), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_IsChannelUseNoValue));
VolumeDataLayout_.def("getChannelNoValue" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelNoValue), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelNoValue));
VolumeDataLayout_.def("getChannelIntegerScale" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelIntegerScale), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelIntegerScale));
VolumeDataLayout_.def("getChannelIntegerOffset" , static_cast<float(VolumeDataLayout::*)(int) const>(&VolumeDataLayout::GetChannelIntegerOffset), py::arg("channel"), OPENVDS_DOCSTRING(VolumeDataLayout_GetChannelIntegerOffset));
//AUTOGEN-END
VolumeDataLayout_.def_property_readonly("dimensions" , static_cast<int(VolumeDataLayout::*)() const>(&VolumeDataLayout::GetDimensionality), OPENVDS_DOCSTRING(VolumeDataLayout_GetDimensionality));
VolumeDataLayout_.def_property_readonly("shape" , [](VolumeDataLayout* self)
{
int dimensions = self->GetDimensionality();
int anVoxelCount[6];
for (int i = 0; i < 6; ++i)
{
anVoxelCount[i] = self->GetDimensionNumSamples(i);
}
switch (dimensions)
{
case 1:
return py::make_tuple(anVoxelCount[0]);
case 2:
return py::make_tuple(anVoxelCount[0], anVoxelCount[1]);
case 3:
return py::make_tuple(anVoxelCount[0], anVoxelCount[1], anVoxelCount[2]);
case 4:
return py::make_tuple(anVoxelCount[0], anVoxelCount[1], anVoxelCount[2], anVoxelCount[3]);
case 5:
return py::make_tuple(anVoxelCount[0], anVoxelCount[1], anVoxelCount[2], anVoxelCount[3], anVoxelCount[4]);
default:
return py::make_tuple(anVoxelCount[0], anVoxelCount[1], anVoxelCount[2], anVoxelCount[3], anVoxelCount[4], anVoxelCount[5]);
}
});
}
......@@ -75,7 +75,7 @@ PyVolumeDataLayoutDescriptor::initModule(py::module& m)
VolumeDataLayoutDescriptor_Options_.value("Options_Create2DLODs" , VolumeDataLayoutDescriptor::Options::Options_Create2DLODs, OPENVDS_DOCSTRING(VolumeDataLayoutDescriptor_Options_Options_Create2DLODs));
VolumeDataLayoutDescriptor_Options_.value("Options_ForceFullResolutionDimension", VolumeDataLayoutDescriptor::Options::Options_ForceFullResolutionDimension, OPENVDS_DOCSTRING(VolumeDataLayoutDescriptor_Options_Options_ForceFullResolutionDimension));
m.def("operator_bor" , static_cast<VolumeDataLayoutDescriptor::Options(*)(VolumeDataLayoutDescriptor::Options, VolumeDataLayoutDescriptor::Options)>(&operator|), OPENVDS_DOCSTRING(operator_bor));
m.def("operator_bor" , static_cast<VolumeDataLayoutDescriptor::Options(*)(VolumeDataLayoutDescriptor::Options, VolumeDataLayoutDescriptor::Options)>(&operator|), py::arg("lhs"), py::arg("rhs"), OPENVDS_DOCSTRING(operator_bor));
//AUTOGEN-END
}
from .core import *
from .api import *
def getTestOpenOptions():
return AWSOpenOptions(TEST_AWS_BUCKET, TEST_AWS_OBJECTID, TEST_AWS_REGION)
import openvds.core
from openvds.core import *
from .volumedataaccess import VolumeDataAccess
def open(options: OpenOptions = None, ioManager: IOManager = None, err: Error = None) -> int:
"""Open an existing VDS
Parameter `options`:
The options for the connection
Parameter `ioManager`:
The IOManager for the connection, it will be deleted automatically
when the VDS handle is closed
Either `options` or `ioManager` must be specified.
Parameter `error`:
If an error occured, the error code and message will be written to
this output parameter
Returns:
The VDS handle that can be used to get the VolumeDataLayout and
the VolumeDataAccessManager
"""
if options:
return openvds.core.open(options, err or openvds.core.Error())
else:
return openvds.core.open(ioManager, err or openvds.core.Error())
def close(handle: int):
"""Close a VDS and free up all associated resources
Parameter `handle`:
The handle of the VDS
"""
openvds.core.close(handle)
\ No newline at end of file
......@@ -33,98 +33,8 @@
#include "PyVolumeDataLayoutDescriptor.h"
#include "PyVolumeSampler.h"
#ifndef TEST_ARRAY_WRAP
#define TEST_ARRAY_WRAP 1
#endif
#if TEST_ARRAY_WRAP
#include <array>
static int sumArray(const int (&data)[6])
{
int sum = 0;
for (int i = 0; i < 6; ++i)
{
sum += data[i];
}
return sum;
}
static void populateArray(int(&data)[6])
{
for (int i = 0; i < 6; ++i)
{
data[i] = 0;
}
}
struct TestArray
{
int m_Data[6];
TestArray()
{
for (int i = 0; i < 6; ++i)
{
m_Data[i] = 0;
}
}
void setValues(const int (&data)[6])
{
for (int i = 0; i < 6; ++i)
{
m_Data[i] = data[i];
}
}
void getValues(int (&data)[6])
{
for (int i = 0; i < 6; ++i)
{
data[i] = m_Data[i];
}
}
};
#endif
PYBIND11_MODULE(core, m) {
#if TEST_ARRAY_WRAP
m.def("sumArray", [](std::array<int, 6> const& data)
{
return sumArray((const int(&)[6])data);
});
m.def("populateArray", [](std::array<int, 6>& data)
{
return populateArray((int(&)[6])data);
});
py::class_<TestArray>(m, "TestArray")
.def(py::init<>())
.def("setValues", [](TestArray* self, py::array_t<int> const& data)
{
return self->setValues((const int(&)[6])*PyArrayAdapter<int, 6, false>::getArrayBufferChecked(data));
},
py::arg().noconvert()
)
.def("getValues", [](TestArray* self, py::array_t<int> data)
{
return self->getValues((int(&)[6])*PyArrayAdapter<int, 6, true>::getArrayBufferChecked(data));
},
py::arg().noconvert()
)
;
m.def("check2Darray", [](py::array_t<int>& data)
{
int arrayCount = 0;
auto& checkedData = PyArrayAdapter<int, 3, false>::getArrayChecked(data, &arrayCount);
return arrayCount;
}
);
#endif
PyGlobal::initModule(m);
PyGlobalMetadataCommon::initModule(m);
PyKnownMetadata::initModule(m);
......
This diff is collapsed.
This diff is collapsed.
......@@ -6,8 +6,8 @@ from clang.cindex import CursorKind
from collections import OrderedDict
filename = 'tmpinclude/OpenVDS/OpenVDS.h'
parameters = ['-x', 'c++', '-std=c++14']
filename = 'tmpinclude/OpenVDS/VolumeDataAccess.h'
parameters = ['-x', 'c++', '-std=c++14', '-I../../src']
RECURSE_LIST = [
CursorKind.TRANSLATION_UNIT,
......@@ -15,7 +15,9 @@ RECURSE_LIST = [
CursorKind.CLASS_DECL,
CursorKind.STRUCT_DECL,
CursorKind.ENUM_DECL,
CursorKind.CLASS_TEMPLATE
CursorKind.CLASS_TEMPLATE,
CursorKind.CXX_METHOD,
CursorKind.FUNCTION_DECL,
]
PRINT_LIST = [
......@@ -30,7 +32,8 @@ PRINT_LIST = [
CursorKind.CXX_METHOD,
CursorKind.CXX_BASE_SPECIFIER,
CursorKind.CONSTRUCTOR,
CursorKind.FIELD_DECL
CursorKind.FIELD_DECL,
CursorKind.PARM_DECL,
]
PREFIX_BLACKLIST = [
......@@ -71,8 +74,9 @@ def dump(all):
index = cindex.Index(cindex.conf.lib.clang_createIndex(False, True))
tu = index.parse(filename, parameters)
nodes = extract_nodes(filename, tu.cursor)
s = [x for x in nodes if x.kind==CursorKind.STRUCT_DECL]
s0=s[0]
s1=s[1]
#s = [x for x in nodes if x.kind==CursorKind.STRUCT_DECL]
#s0=s[0]
#s1=s[1]
dump(nodes)
......@@ -109,16 +109,16 @@ def process_comment(comment):
cpp_group = '([\w:]+)'
param_group = '([\[\w:\]]+)'
s = re.sub(r'\\c\s+%s' % cpp_group, r'``\1``', s)
s = re.sub(r'\\c\s+%s' % cpp_group, r'\1', s)
s = re.sub(r'\\a\s+%s' % cpp_group, r'*\1*', s)
s = re.sub(r'\\e\s+%s' % cpp_group, r'*\1*', s)
s = re.sub(r'\\em\s+%s' % cpp_group, r'*\1*', s)
s = re.sub(r'\\b\s+%s' % cpp_group, r'**\1**', s)
s = re.sub(r'\\ingroup\s+%s' % cpp_group, r'', s)
s = re.sub(r'\\param%s?\s+%s' % (param_group, cpp_group),
r'\n\n$Parameter ``\2``:\n\n', s)
r'\n\n$xxx\2 :\n\n', s)
s = re.sub(r'\\tparam%s?\s+%s' % (param_group, cpp_group),
r'\n\n$Template parameter ``\2``:\n\n', s)
r'\n\n$Template parameter \2 :\n\n', s)
for in_, out_ in {
'return': 'Returns',
......@@ -141,11 +141,11 @@ def process_comment(comment):
s = re.sub(r'\\ref\s*', r'', s)
s = re.sub(r'\\code\s?(.*?)\s?\\endcode',
r"```\n\1\n```\n", s, flags=re.DOTALL)
r"`\n\1\n`\n", s, flags=re.DOTALL)
# HTML/TeX tags
s = re.sub(r'<tt>(.*?)</tt>', r'``\1``', s, flags=re.DOTALL)
s = re.sub(r'<pre>(.*?)</pre>', r"```\n\1\n```\n", s, flags=re.DOTALL)
s = re.sub(r'<tt>(.*?)</tt>', r'\1', s, flags=re.DOTALL)
s = re.sub(r'<pre>(.*?)</pre>', r"`\n\1\n`\n", s, flags=re.DOTALL)
s = re.sub(r'<em>(.*?)</em>', r'*\1*', s, flags=re.DOTALL)
s = re.sub(r'<b>(.*?)</b>', r'**\1**', s, flags=re.DOTALL)
s = re.sub(r'\\f\$(.*?)\\f\$', r'$\1$', s, flags=re.DOTALL)
......@@ -153,8 +153,8 @@ def process_comment(comment):
s = re.sub(r'</?ul>', r'', s)
s = re.sub(r'</li>', r'\n\n', s)
s = s.replace('``true``', '``True``')
s = s.replace('``false``', '``False``')
s = s.replace('true', 'True')
s = s.replace('false', 'False')
# Re-flow text
wrapper = textwrap.TextWrapper()
......@@ -166,12 +166,12 @@ def process_comment(comment):
result = ''
in_code_segment = False
for x in re.split(r'(```)', s):
if x == '```':
for x in re.split(r'(`)', s):
if x == '`':
if not in_code_segment:
result += '```\n'
result += '`\n'
else:
result += '\n```\n\n'
result += '\n`\n\n'
in_code_segment = not in_code_segment
elif in_code_segment:
result += x.strip()
......@@ -325,6 +325,11 @@ def write_header(comments, out_file=sys.stdout):
name_ctr = 1
name_prev = None
for name, _, comment in list(sorted(comments, key=lambda x: (x[0], x[1]))):
comment = comment.replace("Returns:", "Returns:\n--------")
if "xxx" in comment:
pre = comment[:comment.index("xxx")]
post = post=comment[comment.index("xxx")+3:].replace("xxx", "")
comment = pre + "Parameters:\n-----------\n\n" + post
if name == name_prev:
name_ctr += 1
name = name + "_%i" % name_ctr
......
......@@ -35,7 +35,9 @@ RECURSE_LIST = [
CursorKind.CLASS_DECL,
CursorKind.STRUCT_DECL,
CursorKind.ENUM_DECL,
# CursorKind.CLASS_TEMPLATE
# CursorKind.CLASS_TEMPLATE,
CursorKind.CXX_METHOD,
CursorKind.FUNCTION_DECL,
]
PRINT_LIST = [
......@@ -51,7 +53,8 @@ PRINT_LIST = [
CursorKind.CXX_BASE_SPECIFIER,
CursorKind.CONSTRUCTOR,
CursorKind.DESTRUCTOR,
CursorKind.FIELD_DECL
CursorKind.FIELD_DECL,
CursorKind.PARM_DECL,
]
PREFIX_BLACKLIST = [
......@@ -138,7 +141,9 @@ def getparent(node, all_):
def getchildren(node, all_, kind=None, access_filter = PUBLIC_LIST):
children = list(node.get_children())
return [x for x in all_ if x in children and (kind is None or x.kind == kind) and x.access_specifier in access_filter]
children = [x for x in children if (kind is None or x.kind == kind)]
children = [x for x in children if x.access_specifier in access_filter]
return children
def getbases(node, all_):
return getchildren(node, all_, CursorKind.CXX_BASE_SPECIFIER)
......@@ -239,19 +244,20 @@ def get_adapter_type(native_type):
else:
return native_type
def try_generate_trampoline_function(node, all_, restype, arglist):
def try_generate_trampoline_function(node, all_, restype, arglist, params):
args = arglist[1:-1].split(',')
newargs = []
iarg = 0
callargs = []
call_prefix = ''
argnames = ''
if node.kind == CursorKind.CXX_METHOD:
instance_arg = "{}* self".format(getnativename(getparent(node, all_), all_))
newargs.append(instance_arg)
call_prefix = 'self->'
for arg in args:
for p in params:
arg, argname = p
arg = arg.strip()
argname = "arg{}".format(iarg)
argnames += ', py::arg("{}")'.format(argname)
if '[' in arg:
m=re.match(r"(.+)\((.+)\)\[(.+)\]", arg)
if m:
......@@ -289,19 +295,21 @@ def try_generate_trampoline_function(node, all_, restype, arglist):
else:
callargs.append(argname)
newargs.append("{} {}".format(arg, argname))
iarg += 1
call = "{}{}({})".format(call_prefix, node.spelling, ", ".join(callargs))
if 'Vector' in restype:
restype = get_adapter_type(restype)
call = "({}::AdaptedType)({})".format(restype, call)
newarglist = ", ".join(newargs)
sig = "[]({}) BEGIN return {}; END".format(newarglist, call).replace('BEGIN', '{').replace('END', '}')