void NTNDArrayRecord::setDimension(const int32_t * dims, size_t ndims) { // Get the dimension field PVStructureArrayPtr dimField = ndarray->getDimension(); // create a shared_vector or try to reuse the dimension field's one PVStructureArray::svector dimVector(dimField->reuse()); // resize/reserve the number of elements dimVector.resize(ndims); // Iterate over the number of dimensions, creating and adding the // appropriate dimension structures. for (size_t i = 0; i < ndims; i++) { PVStructurePtr d = dimVector[i]; // If d is null or not unique create a new PVStructure if (!d || !d.unique()) d = dimVector[i] = getPVDataCreate()->createPVStructure(dimField->getStructureArray()->getStructure()); // Set the size, offset, fullSize, binning and reverse fields // (binning should be 1) d->getSubField<PVInt>("size")->put(dims[i]); d->getSubField<PVInt>("offset")->put(0); d->getSubField<PVInt>("fullSize")->put(dims[i]); d->getSubField<PVInt>("binning")->put(1); d->getSubField<PVBoolean>("reverse")->put(false); } // replace the dimensions field's shared_vector // (Remember to freeze first) dimField->replace(freeze(dimVector)); }
XDMFBINARYCONTROLLER * XdmfBinaryControllerNewHyperslab(char * filePath, int type, int endian, unsigned int seek, unsigned int * start, unsigned int * stride, unsigned int * dimensions, unsigned int * dataspaceDimensions, unsigned int numDims, int * status) { XDMF_ERROR_WRAP_START(status) std::vector<unsigned int> startVector(start, start + numDims); std::vector<unsigned int> strideVector(stride, stride + numDims); std::vector<unsigned int> dimVector(dimensions, dimensions + numDims); std::vector<unsigned int> dataspaceVector(dataspaceDimensions, dataspaceDimensions + numDims); shared_ptr<const XdmfArrayType> buildType = shared_ptr<XdmfArrayType>(); switch (type) { case XDMF_ARRAY_TYPE_UINT8: buildType = XdmfArrayType::UInt8(); break; case XDMF_ARRAY_TYPE_UINT16: buildType = XdmfArrayType::UInt16(); break; case XDMF_ARRAY_TYPE_UINT32: buildType = XdmfArrayType::UInt32(); break; case XDMF_ARRAY_TYPE_INT8: buildType = XdmfArrayType::Int8(); break; case XDMF_ARRAY_TYPE_INT16: buildType = XdmfArrayType::Int16(); break; case XDMF_ARRAY_TYPE_INT32: buildType = XdmfArrayType::Int32(); break; case XDMF_ARRAY_TYPE_INT64: buildType = XdmfArrayType::Int64(); break; case XDMF_ARRAY_TYPE_FLOAT32: buildType = XdmfArrayType::Float32(); break; case XDMF_ARRAY_TYPE_FLOAT64: buildType = XdmfArrayType::Float64(); break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid ArrayType."); break; } XdmfBinaryController::Endian buildEndian = XdmfBinaryController::NATIVE; switch (endian) { case XDMF_BINARY_CONTROLLER_ENDIAN_BIG: buildEndian = XdmfBinaryController::BIG; break; case XDMF_BINARY_CONTROLLER_ENDIAN_LITTLE: buildEndian = XdmfBinaryController::LITTLE; break; case XDMF_BINARY_CONTROLLER_ENDIAN_NATIVE: buildEndian = XdmfBinaryController::NATIVE; break; default: XdmfError::message(XdmfError::FATAL, "Error: Invalid Endian."); break; } shared_ptr<XdmfBinaryController> generatedController = XdmfBinaryController::New(std::string(filePath), buildType, buildEndian, seek, startVector, strideVector, dimVector, dataspaceVector); return (XDMFBINARYCONTROLLER *)((void *)(new XdmfBinaryController(*generatedController.get()))); XDMF_ERROR_WRAP_END(status) return NULL; }