Fesapi 2.10.1.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
Loading...
Searching...
No Matches
ContinuousProperty.h
1/*-----------------------------------------------------------------------
2Licensed to the Apache Software Foundation (ASF) under one
3or more contributor license agreements. See the NOTICE file
4distributed with this work for additional information
5regarding copyright ownership. The ASF licenses this file
6to you under the Apache License, Version 2.0 (the
7"License"; you may not use this file except in compliance
8with the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing,
13software distributed under the License is distributed on an
14"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15KIND, either express or implied. See the License for the
16specific language governing permissions and limitations
17under the License.
18-----------------------------------------------------------------------*/
19#pragma once
20
21#include "AbstractValuesProperty.h"
22#include "../eml2/AbstractHdfProxy.h"
23
24#include <stdexcept>
25
26namespace RESQML2_NS
27{
38 {
39 public:
40
42 virtual ~ContinuousProperty() = default;
43
47 std::string pushBackRefToExistingIntegerDataset(EML2_NS::AbstractHdfProxy*, const std::string&, int64_t) final {
48 throw std::logic_error("You cannot push back integer values in a Continuous Property.");
49 }
50
59 DLL_IMPORT_OR_EXPORT virtual gsoap_resqml2_0_1::resqml20__ResqmlUom getUom() const = 0;
60
66 DLL_IMPORT_OR_EXPORT virtual std::string getUomAsString() const = 0;
67
88 DLL_IMPORT_OR_EXPORT void pushBackDoubleHdf5Array1dOfValues(const double * values, uint64_t valueCount,
89 double minimumValue, double maximumValue, EML2_NS::AbstractHdfProxy* proxy = nullptr);
90 using AbstractValuesProperty::pushBackDoubleHdf5Array1dOfValues;
91
116 DLL_IMPORT_OR_EXPORT void pushBackDoubleHdf5Array2dOfValues(const double * values, uint64_t valueCountInFastestDim, uint64_t valueCountInSlowestDim,
117 double minimumValue, double maximumValue, EML2_NS::AbstractHdfProxy* proxy = nullptr);
118 using AbstractValuesProperty::pushBackDoubleHdf5Array2dOfValues;
119
146 DLL_IMPORT_OR_EXPORT void pushBackDoubleHdf5Array3dOfValues(const double * values, uint64_t valueCountInFastestDim, uint64_t valueCountInMiddleDim, uint64_t valueCountInSlowestDim,
147 double minimumValue, double maximumValue, EML2_NS::AbstractHdfProxy* proxy = nullptr);
148 using AbstractValuesProperty::pushBackDoubleHdf5Array3dOfValues;
149
177 DLL_IMPORT_OR_EXPORT void pushBackDoubleHdf5ArrayOfValues(double const * values, uint64_t const * numValues, unsigned int numArrayDimensions,
178 double * minimumValue, double * maximumValue, EML2_NS::AbstractHdfProxy* proxy = nullptr);
179 using AbstractValuesProperty::pushBackDoubleHdf5ArrayOfValues;
180
186 DLL_IMPORT_OR_EXPORT void pushBackFloatHdf5Array1dOfValues(const float * values, uint64_t valueCount,
187 float minimumValue, float maximumValue, EML2_NS::AbstractHdfProxy* proxy = nullptr);
188 using AbstractValuesProperty::pushBackFloatHdf5Array1dOfValues;
189
195 DLL_IMPORT_OR_EXPORT void pushBackFloatHdf5Array2dOfValues(const float * values, uint64_t valueCountInFastestDim, uint64_t valueCountInSlowestDim,
196 float minimumValue, float maximumValue, EML2_NS::AbstractHdfProxy* proxy = nullptr);
197 using AbstractValuesProperty::pushBackFloatHdf5Array2dOfValues;
198
204 DLL_IMPORT_OR_EXPORT void pushBackFloatHdf5Array3dOfValues(const float * values, uint64_t valueCountInFastestDim, uint64_t valueCountInMiddleDim, uint64_t valueCountInSlowestDim,
205 float minimumValue, float maximumValue, EML2_NS::AbstractHdfProxy* proxy = nullptr);
206 using AbstractValuesProperty::pushBackFloatHdf5Array3dOfValues;
207
216 DLL_IMPORT_OR_EXPORT void pushBackFloatHdf5ArrayOfValues(float const * values, uint64_t const * numValues, unsigned int numArrayDimensions,
217 float * minimumValue, float * maximumValue, EML2_NS::AbstractHdfProxy* proxy = nullptr);
218 using AbstractValuesProperty::pushBackFloatHdf5ArrayOfValues;
219
233 DLL_IMPORT_OR_EXPORT virtual double getMinimumValue(unsigned int index = 0) const = 0;
234
248 DLL_IMPORT_OR_EXPORT virtual double getMaximumValue(unsigned int index = 0) const = 0;
249
259 DLL_IMPORT_OR_EXPORT virtual void setMinimumValue(double value, unsigned int index = 0) const = 0;
260
270 DLL_IMPORT_OR_EXPORT virtual void setMaximumValue(double value, unsigned int index = 0) const = 0;
271
272 //***************************
273 //*** For hyperslabbing *****
274 //***************************
275
299 DLL_IMPORT_OR_EXPORT void pushBackHdf5ArrayOfValues(
300 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
301 uint64_t const * numValues,
302 unsigned int numArrayDimensions,
303 double * minimumValue, double * maximumValue,
304 EML2_NS::AbstractHdfProxy* proxy = nullptr
305 );
306 using AbstractValuesProperty::pushBackHdf5ArrayOfValues;
307
329 DLL_IMPORT_OR_EXPORT void pushBackHdf5Array1dOfValues(
330 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
331 uint64_t valueCount,
332 double minimumValue, double maximumValue,
333 EML2_NS::AbstractHdfProxy* proxy = nullptr
334 );
335 using AbstractValuesProperty::pushBackHdf5Array1dOfValues;
336
361 DLL_IMPORT_OR_EXPORT void pushBackHdf5Array2dOfValues(
362 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
363 uint64_t valueCountInFastestDim,
364 uint64_t valueCountInMiddleDim,
365 double minimumValue, double maximumValue,
366 EML2_NS::AbstractHdfProxy* proxy = nullptr
367 );
368 using AbstractValuesProperty::pushBackHdf5Array2dOfValues;
369
396 DLL_IMPORT_OR_EXPORT void pushBackHdf5Array3dOfValues(
397 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
398 uint64_t valueCountInFastestDim,
399 uint64_t valueCountInMiddleDim,
400 uint64_t valueCountInSlowestDim,
401 double minimumValue, double maximumValue,
402 EML2_NS::AbstractHdfProxy* proxy = nullptr
403 );
404 using AbstractValuesProperty::pushBackHdf5Array3dOfValues;
405
445 DLL_IMPORT_OR_EXPORT void setValuesOfFloatHdf5Array3dOfValues(
446 float const * values,
447 uint64_t valueCountInFastestDim,
448 uint64_t valueCountInMiddleDim,
449 uint64_t valueCountInSlowestDim,
450 uint64_t offsetInFastestDim,
451 uint64_t offsetInMiddleDim,
452 uint64_t offsetInSlowestDim,
453 bool computeMinMax,
454 EML2_NS::AbstractHdfProxy* proxy = nullptr,
455 uint64_t patchIndex = (std::numeric_limits<uint64_t>::max)()
456 );
457 using AbstractValuesProperty::setValuesOfFloatHdf5Array3dOfValues;
458 DLL_IMPORT_OR_EXPORT void setValuesOfDoubleHdf5Array3dOfValues(
459 double const * values,
460 uint64_t valueCountInFastestDim,
461 uint64_t valueCountInMiddleDim,
462 uint64_t valueCountInSlowestDim,
463 uint64_t offsetInFastestDim,
464 uint64_t offsetInMiddleDim,
465 uint64_t offsetInSlowestDim,
466 bool computeMinMax,
467 EML2_NS::AbstractHdfProxy* proxy = nullptr,
468 uint64_t patchIndex = (std::numeric_limits<uint64_t>::max)()
469 );
470 using AbstractValuesProperty::setValuesOfDoubleHdf5Array3dOfValues;
471
505 DLL_IMPORT_OR_EXPORT void setValuesOfFloatHdf5ArrayOfValues(
506 float const * values,
507 uint64_t const * numValues,
508 uint64_t const * offsetValues,
509 unsigned int numArrayDimensions,
510 bool computeMinMax,
511 EML2_NS::AbstractHdfProxy* proxy = nullptr,
512 uint64_t patchIndex = (std::numeric_limits<uint64_t>::max)()
513 );
514 using AbstractValuesProperty::setValuesOfFloatHdf5ArrayOfValues;
515
516 DLL_IMPORT_OR_EXPORT void setValuesOfDoubleHdf5ArrayOfValues(
517 double const * values,
518 uint64_t const * numValues,
519 uint64_t const * offsetValues,
520 unsigned int numArrayDimensions,
521 bool computeMinMax,
522 EML2_NS::AbstractHdfProxy* proxy = nullptr,
523 uint64_t patchIndex = (std::numeric_limits<uint64_t>::max)()
524 );
525 using AbstractValuesProperty::setValuesOfDoubleHdf5ArrayOfValues;
526
528 DLL_IMPORT_OR_EXPORT static const char* XML_TAG;
529
530 DLL_IMPORT_OR_EXPORT virtual std::string getXmlTag() const final { return XML_TAG; }
531
532 protected:
533
539 DLL_IMPORT_OR_EXPORT ContinuousProperty(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject) : RESQML2_NS::AbstractValuesProperty(partialObject) {}
540
542 ContinuousProperty() {}
543
549 ContinuousProperty(gsoap_resqml2_0_1::_resqml20__ContinuousProperty* fromGsoap) : AbstractValuesProperty(fromGsoap) {}
550
556 ContinuousProperty(gsoap_eml2_3::_resqml22__ContinuousProperty* fromGsoap) : AbstractValuesProperty(fromGsoap) {}
557
558 virtual size_t getMinimumValueSize() const = 0;
559 virtual size_t getMaximumValueSize() const = 0;
560
561 private:
562
579 template <class T>
580 void setPropertyMinMax(
581 T const * values,
582 uint64_t const * numValuesInEachDimension,
583 unsigned int numArrayDimensions,
584 T * minimumValue = nullptr, T * maximumValue = nullptr)
585 {
586 const unsigned int elementCount = getElementCountPerValue();
587
588 // Some minimum and maximum values are given : No need to compute them.
589 if (minimumValue != nullptr) {
590 for (unsigned int propIndex = 0; propIndex < elementCount; ++propIndex) {
591 setMinimumValue(getMinimumValueSize() > propIndex ? fmin(getMinimumValue(propIndex), minimumValue[propIndex]) : minimumValue[propIndex], propIndex);
592 }
593 }
594 if (maximumValue != nullptr) {
595 for (unsigned int propIndex = 0; propIndex < elementCount; ++propIndex) {
596 setMaximumValue(getMaximumValueSize() > propIndex ? fmax(getMaximumValue(propIndex), maximumValue[propIndex]) : maximumValue[propIndex], propIndex);
597 }
598 }
599 if (minimumValue != nullptr && maximumValue != nullptr) return; // No need to compute max or min value
600
601 uint64_t nValues = numValuesInEachDimension[0];
602 //If count > 1, the last (fastest) dimension has the number of properties per indexable element of the representation.
603 for (unsigned int dim = 1; dim < (elementCount == 1 ? numArrayDimensions : numArrayDimensions - 1); ++dim) {
604 nValues *= numValuesInEachDimension[dim];
605 }
606
607 // Minimum or maximum values are not given : Need to compute them.
608 std::unique_ptr<T[]> allComputedMin(new T[elementCount]);
609 std::unique_ptr<T[]> allComputedMax(new T[elementCount]);
610 for (size_t propIndex = 0; propIndex < elementCount; ++propIndex) {
611 allComputedMin[propIndex] = std::numeric_limits<T>::quiet_NaN();
612 allComputedMax[propIndex] = std::numeric_limits<T>::quiet_NaN();
613 for (size_t i = 0; i < nValues; i += elementCount) {
614 allComputedMin[propIndex] = fmin(allComputedMin[propIndex], values[i]);
615 allComputedMax[propIndex] = fmax(allComputedMax[propIndex], values[i]);
616 }
617 }
618 setPropertyMinMax(values, numValuesInEachDimension, numArrayDimensions, allComputedMin.get(), allComputedMax.get());
619 }
620 };
621}
Proxy class for an abstract values property.
Definition AbstractValuesProperty.h:27
Proxy class for a continuous property. Most common type of property used for storing rock or fluid at...
Definition ContinuousProperty.h:38
void pushBackDoubleHdf5Array1dOfValues(const double *values, uint64_t valueCount, double minimumValue, double maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
Adds a 1d array of explicit double values to the property values.
virtual std::string getUomAsString() const =0
void pushBackHdf5Array1dOfValues(common::AbstractObject::numericalDatatypeEnum datatype, uint64_t valueCount, double minimumValue, double maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
void pushBackDoubleHdf5ArrayOfValues(double const *values, uint64_t const *numValues, unsigned int numArrayDimensions, double *minimumValue, double *maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
Adds an nd array of explicit double values to the property values.
virtual gsoap_resqml2_0_1::resqml20__ResqmlUom getUom() const =0
void pushBackHdf5Array3dOfValues(common::AbstractObject::numericalDatatypeEnum datatype, uint64_t valueCountInFastestDim, uint64_t valueCountInMiddleDim, uint64_t valueCountInSlowestDim, double minimumValue, double maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
void pushBackFloatHdf5ArrayOfValues(float const *values, uint64_t const *numValues, unsigned int numArrayDimensions, float *minimumValue, float *maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
virtual void setMinimumValue(double value, unsigned int index=0) const =0
Sets the minimum value of a non vector property or the minimum value of one given value of a vector p...
void setValuesOfFloatHdf5ArrayOfValues(float const *values, uint64_t const *numValues, uint64_t const *offsetValues, unsigned int numArrayDimensions, bool computeMinMax, eml2::AbstractHdfProxy *proxy=nullptr, uint64_t patchIndex=(std::numeric_limits< uint64_t >::max)())
void pushBackFloatHdf5Array1dOfValues(const float *values, uint64_t valueCount, float minimumValue, float maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
void pushBackFloatHdf5Array3dOfValues(const float *values, uint64_t valueCountInFastestDim, uint64_t valueCountInMiddleDim, uint64_t valueCountInSlowestDim, float minimumValue, float maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
void pushBackDoubleHdf5Array2dOfValues(const double *values, uint64_t valueCountInFastestDim, uint64_t valueCountInSlowestDim, double minimumValue, double maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
Adds a 2d array of explicit double values to the property values.
void pushBackHdf5Array2dOfValues(common::AbstractObject::numericalDatatypeEnum datatype, uint64_t valueCountInFastestDim, uint64_t valueCountInMiddleDim, double minimumValue, double maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
virtual double getMinimumValue(unsigned int index=0) const =0
Gets the minimum value of a non vector property or the minimum value of one given value of a vector p...
void pushBackFloatHdf5Array2dOfValues(const float *values, uint64_t valueCountInFastestDim, uint64_t valueCountInSlowestDim, float minimumValue, float maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
virtual double getMaximumValue(unsigned int index=0) const =0
Gets the maximum value of a non vector property or the maximum value of one given value of a vector p...
static const char * XML_TAG
Definition ContinuousProperty.h:528
std::string pushBackRefToExistingIntegerDataset(eml2::AbstractHdfProxy *, const std::string &, int64_t) final
Definition ContinuousProperty.h:47
virtual void setMaximumValue(double value, unsigned int index=0) const =0
Sets the maximum value of a non vector property or the maximum value of one given value of a vector p...
virtual ~ContinuousProperty()=default
void setValuesOfFloatHdf5Array3dOfValues(float const *values, uint64_t valueCountInFastestDim, uint64_t valueCountInMiddleDim, uint64_t valueCountInSlowestDim, uint64_t offsetInFastestDim, uint64_t offsetInMiddleDim, uint64_t offsetInSlowestDim, bool computeMinMax, eml2::AbstractHdfProxy *proxy=nullptr, uint64_t patchIndex=(std::numeric_limits< uint64_t >::max)())
void pushBackDoubleHdf5Array3dOfValues(const double *values, uint64_t valueCountInFastestDim, uint64_t valueCountInMiddleDim, uint64_t valueCountInSlowestDim, double minimumValue, double maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
Adds a 3d array of explicit double values to the property values.
virtual std::string getXmlTag() const final
Definition ContinuousProperty.h:530
void pushBackHdf5ArrayOfValues(common::AbstractObject::numericalDatatypeEnum datatype, uint64_t const *numValues, unsigned int numArrayDimensions, double *minimumValue, double *maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)