Fesapi  2.0.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
ContinuousProperty.h
1 /*-----------------------------------------------------------------------
2 Licensed to the Apache Software Foundation (ASF) under one
3 or more contributor license agreements. See the NOTICE file
4 distributed with this work for additional information
5 regarding copyright ownership. The ASF licenses this file
6 to you under the Apache License, Version 2.0 (the
7 "License"; you may not use this file except in compliance
8 with the License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing,
13 software distributed under the License is distributed on an
14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 KIND, either express or implied. See the License for the
16 specific language governing permissions and limitations
17 under the License.
18 -----------------------------------------------------------------------*/
19 #pragma once
20 
21 #include "AbstractValuesProperty.h"
22 #include "../eml2/AbstractHdfProxy.h"
23 
24 #include <stdexcept>
25 
26 namespace 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, unsigned long long 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, unsigned long long 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 pushBackFloatHdf5ArrayOfValues(
300  unsigned long long const * numValues,
301  unsigned int numArrayDimensions,
302  float * minimumValue, float * maximumValue,
303  EML2_NS::AbstractHdfProxy* proxy = nullptr
304  );
305 
331  DLL_IMPORT_OR_EXPORT void pushBackFloatHdf5Array3dOfValues(
332  uint64_t valueCountInFastestDim,
333  uint64_t valueCountInMiddleDim,
334  uint64_t valueCountInSlowestDim,
335  float minimumValue, float maximumValue,
336  EML2_NS::AbstractHdfProxy* proxy = nullptr
337  );
338 
378  DLL_IMPORT_OR_EXPORT void setValuesOfFloatHdf5Array3dOfValues(
379  float const * values,
380  uint64_t valueCountInFastestDim,
381  uint64_t valueCountInMiddleDim,
382  uint64_t valueCountInSlowestDim,
383  uint64_t offsetInFastestDim,
384  uint64_t offsetInMiddleDim,
385  uint64_t offsetInSlowestDim,
386  bool computeMinMax,
387  EML2_NS::AbstractHdfProxy* proxy = nullptr,
388  unsigned int patchIndex = (std::numeric_limits<unsigned int>::max)()
389  );
390  using AbstractValuesProperty::setValuesOfFloatHdf5Array3dOfValues;
391 
425  DLL_IMPORT_OR_EXPORT void setValuesOfFloatHdf5ArrayOfValues(
426  float const * values,
427  unsigned long long const * numValues,
428  unsigned long long const * offsetValues,
429  unsigned int numArrayDimensions,
430  bool computeMinMax,
431  EML2_NS::AbstractHdfProxy* proxy = nullptr,
432  unsigned int patchIndex = (std::numeric_limits<unsigned int>::max)()
433  );
434  using AbstractValuesProperty::setValuesOfFloatHdf5ArrayOfValues;
435 
437  DLL_IMPORT_OR_EXPORT static const char* XML_TAG;
438 
439  DLL_IMPORT_OR_EXPORT virtual std::string getXmlTag() const final { return XML_TAG; }
440 
441  protected:
442 
448  DLL_IMPORT_OR_EXPORT ContinuousProperty(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject) : RESQML2_NS::AbstractValuesProperty(partialObject) {}
449 
451  ContinuousProperty() {}
452 
458  ContinuousProperty(gsoap_resqml2_0_1::_resqml20__ContinuousProperty* fromGsoap) : AbstractValuesProperty(fromGsoap) {}
459 
465  ContinuousProperty(gsoap_eml2_3::_resqml22__ContinuousProperty* fromGsoap) : AbstractValuesProperty(fromGsoap) {}
466 
467  virtual size_t getMinimumValueSize() const = 0;
468  virtual size_t getMaximumValueSize() const = 0;
469 
470  private:
471 
488  template <class T>
489  void setPropertyMinMax(
490  T const * values,
491  unsigned long long const * numValuesInEachDimension,
492  unsigned int numArrayDimensions,
493  T * minimumValue = nullptr, T * maximumValue = nullptr)
494  {
495  const unsigned int elementCount = getElementCountPerValue();
496 
497  // Some minimum and maximum values are given : No need to compute them.
498  if (minimumValue != nullptr) {
499  for (size_t propIndex = 0; propIndex < elementCount; ++propIndex) {
500  setMinimumValue(getMinimumValueSize() > propIndex ? fmin(getMinimumValue(propIndex), minimumValue[propIndex]) : minimumValue[propIndex], propIndex);
501  }
502  }
503  if (maximumValue != nullptr) {
504  for (size_t propIndex = 0; propIndex < elementCount; ++propIndex) {
505  setMaximumValue(getMaximumValueSize() > propIndex ? fmax(getMaximumValue(propIndex), maximumValue[propIndex]) : maximumValue[propIndex], propIndex);
506  }
507  }
508  if (minimumValue != nullptr && maximumValue != nullptr) return; // No need to compute max or min value
509 
510  uint64_t nValues = numValuesInEachDimension[0];
511  //If count > 1, the last (fastest) dimension has the number of properties per indexable element of the representation.
512  for (unsigned int dim = 1; dim < (elementCount == 1 ? numArrayDimensions : numArrayDimensions - 1); ++dim) {
513  nValues *= numValuesInEachDimension[dim];
514  }
515 
516  // Minimum or maximum values are not given : Need to compute them.
517  std::unique_ptr<T[]> allComputedMin(new T[elementCount]);
518  std::unique_ptr<T[]> allComputedMax(new T[elementCount]);
519  for (size_t propIndex = 0; propIndex < elementCount; ++propIndex) {
520  allComputedMin[propIndex] = std::numeric_limits<T>::quiet_NaN();
521  allComputedMax[propIndex] = std::numeric_limits<T>::quiet_NaN();
522  for (size_t i = 0; i < nValues; i += elementCount) {
523  allComputedMin[propIndex] = fmin(allComputedMin[propIndex], values[i]);
524  allComputedMax[propIndex] = fmax(allComputedMax[propIndex], values[i]);
525  }
526  }
527  setPropertyMinMax(values, numValuesInEachDimension, numArrayDimensions, allComputedMin.get(), allComputedMax.get());
528  }
529  };
530 }
Proxy class for an abstract values property.
Definition: AbstractValuesProperty.h:28
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.
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, unsigned int patchIndex=(std::numeric_limits< unsigned int >::max)())
void pushBackFloatHdf5Array3dOfValues(uint64_t valueCountInFastestDim, uint64_t valueCountInMiddleDim, uint64_t valueCountInSlowestDim, float minimumValue, float maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
virtual std::string getUomAsString() const =0
void setValuesOfFloatHdf5ArrayOfValues(float const *values, unsigned long long const *numValues, unsigned long long const *offsetValues, unsigned int numArrayDimensions, bool computeMinMax, eml2::AbstractHdfProxy *proxy=nullptr, unsigned int patchIndex=(std::numeric_limits< unsigned int >::max)())
void pushBackFloatHdf5ArrayOfValues(unsigned long long const *numValues, unsigned int numArrayDimensions, float *minimumValue, float *maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
virtual gsoap_resqml2_0_1::resqml20__ResqmlUom getUom() const =0
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 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 pushBackDoubleHdf5ArrayOfValues(double const *values, unsigned long long 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 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:437
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...
void pushBackFloatHdf5ArrayOfValues(float const *values, unsigned long long const *numValues, unsigned int numArrayDimensions, float *minimumValue, float *maximumValue, eml2::AbstractHdfProxy *proxy=nullptr)
virtual ~ContinuousProperty()=default
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:439