OpenZGY/C++ API and Internals (ALPHA)
Access seismic data stored in ZGY format.
Classes | Typedefs | Enumerations | Functions
InternalZGY Namespace Reference

Implementation not visible to clients. More...

Classes

class  CompressFactoryImpl
 Registry of known compress and decompress algorithms. More...
 
class  Config
 
class  DataBuffer
 Each DataBuffer instance represents some in memory data. More...
 
class  DataBufferNd
 
class  Environment
 
class  FileADT
 
class  FileCommon
 Implementation of some methods that might be shared. More...
 
class  FileConfig
 
class  FileFactory
 
class  FileHeaderAccess
 
class  FileHeaderPOD
 
class  FileUtilsSeismicStore
 
class  GenLodBase
 
class  GenLodC
 
class  GenLodImpl
 
class  GUID
 Simplified GUID handling. Only big endian, random number guids. More...
 
class  HeaderAccessFactory
 
class  HistHeaderAccess
 
class  HistHeaderV1Access
 
class  HistHeaderV1POD
 Physical layout of Histogram Header version 1. More...
 
class  HistHeaderV2Access
 
class  HistHeaderV2POD
 Physical layout of Histogram Header version 2 and 3. More...
 
class  HistogramBuilder
 Collect statistics and histogram for bulk data. More...
 
class  HistogramData
 A histogram for a data set. More...
 
class  IFileHeaderAccess
 
class  IHeaderAccess
 
class  IHistHeaderAccess
 
class  IInfoHeaderAccess
 
struct  IJK
 
class  ILookupTableAccess
 
class  ImplicitLinearTransform2d
 
class  ImplicitLinearTransform2dImp
 
class  InfoHeaderAccess
 
class  InfoHeaderV1Access
 
class  InfoHeaderV1POD
 Physical layout of Info Header version 1. More...
 
class  InfoHeaderV2Access
 
class  InfoHeaderV2POD
 Physical layout of Info Header version 2 and 3. More...
 
class  IOffsetHeaderAccess
 
class  LocalFileLinux
 
class  LodAllZero
 Set the low resolution data to all zeros. More...
 
class  LodAverage
 Arithmetic average of 8 neighboring integer samples. More...
 
class  LodAverage< float >
 Arithmetic average of 8 neighboring float samples, ignoring NaN. More...
 
class  LodAverageNon0
 Arithmetic average, excluding zero, of integer data. More...
 
class  LodAverageNon0< float >
 Arithmetic average, excluding NaN and zero, of float data. More...
 
class  LodDecimate
 Use just one of the 8 input values. More...
 
class  LodDecimateSkipNaN
 Use just one of the 8 integral input values. More...
 
class  LodDecimateSkipNaN< float >
 Use just one of the 8 float input values, looking for one not NaN. More...
 
class  LodMaximum
 Maximum of 8 neighboring samples, excluding NaN. More...
 
class  LodMedian
 Median of 8 neighboring integer samples. More...
 
class  LodMedian< float >
 Median of 8 neighboring float samples, ignoring NaN. More...
 
class  LodMinimum
 Minimum of 8 neighboring samples, excluding NaN. More...
 
class  LodMinMax
 Weird algorithm, probably not useful. More...
 
class  LodMostFrequent
 Most frequent value. More...
 
class  LodSampling
 Static methods for downsampling. Used by lodalgo.cpp only. More...
 
class  LodWeightedAverage
 Weighted arithmetic average of 8 neighboring samples. More...
 
class  Logger
 
class  LoggerBase
 
class  LookupTable
 Static methods to assist working with lookup tables. More...
 
class  LookupTableV0Access
 
struct  LutInfoEx
 
class  NullCompressPlugin
 Example compression plug-in that always fails to compress. More...
 
class  OffsetHeaderAccess
 
class  OffsetHeaderV1Access
 
class  OffsetHeaderV1POD
 Physical layout of Offset Header version 1. More...
 
class  OffsetHeaderV2Access
 
class  OffsetHeaderV2POD
 Physical layout of Offser Header version 2 and 3 (empty). More...
 
class  OrderedCornerPoints
 
class  PrintingTimer
 Timer that prints its result when going out of scope. More...
 
class  PushEnvironment
 
class  RawDataTypeDetails
 
struct  RawDataTypeTraits
 
struct  RawDataTypeTraits< float >
 
struct  RawDataTypeTraits< std::int16_t >
 
struct  RawDataTypeTraits< std::int32_t >
 
struct  RawDataTypeTraits< std::int8_t >
 
struct  RawDataTypeTraits< std::uint16_t >
 
struct  RawDataTypeTraits< std::uint32_t >
 
struct  RawDataTypeTraits< std::uint8_t >
 
class  RawPrintingTimer
 Timer that prints its result when going out of scope. More...
 
class  ReadRequest
 
class  SimpleTimer
 Timer that knows where to store the result. More...
 
class  StatisticData
 Holds the result of computing statistics. More...
 
class  SummaryPrintingTimer
 SummaryTimer that prints its result when going out of scope. More...
 
class  SummaryTimer
 Hold the timing results from zero or more Timer instances. More...
 
class  Timer
 
struct  TmpLookupEntry
 
class  ZgyInternalBulk
 
class  ZgyInternalMeta
 
class  ZgyInternalWriterArgs
 Internal counterpart to OpenZGY::ZgyWriterArgs. More...
 

Typedefs

typedef std::array< std::int64_t, 3 > index3_t
 type equivalent to std::int64_t[3] More...
 
typedef std::pair< std::shared_ptr< const void >, std::int64_t > rawdata_t
 Shared data plus size. No other information. More...
 
typedef std::function< rawdata_t(const rawdata_t &, const index3_t &)> compressor_t
 Function for compressing a brick. More...
 
typedef std::vector< ReadRequestReadList
 
typedef std::vector< ReadList > ReadDoubleList
 

Enumerations

enum  RawDataType {
  SignedInt8 = 0, UnsignedInt8 = 1, SignedInt16 = 2, UnsignedInt16 = 3,
  SignedInt32 = 4, UnsignedInt32 = 5, Float32 = 6, IbmFloat32 = 7
}
 
enum  RawCoordType {
  Unknown = 0, Meters = 1, Feet = 2, ArcSec = 3,
  ArcDeg = 4, ArcDegMinSec = 5
}
 
enum  RawHorizontalDimension { Unknown = 0, Length = 1, ArcAngle = 2 }
 
enum  RawVerticalDimension { Unknown = 0, Depth = 1, SeismicTWT = 2, SeismicOWT = 3 }
 
enum  RawGridDefinition { Unknown = 0, Parametric = 1, ThreePoint = 2, FourPoint = 3 }
 
enum  BrickStatus { Missing = 0, Constant = 1, Normal = 2, Compressed = 3 }
 
enum  UpdateMode { Never = 0, Constant = 1, Always = 4, Pedantic = 5 }
 
enum  OpenMode { Closed = 0, ReadOnly, ReadWrite, Truncate }
 
enum  UsageHint {
  Unknown = 0x00, TextFile = 0x01, Header = 0x10, Data = 0x20,
  Compressed = 0x40, Mixed = 0x40
}
 
enum  LodAlgorithm {
  LodAlgorithm::LowPass = 0, LodAlgorithm::WeightedAverage, LodAlgorithm::Average, LodAlgorithm::Median,
  LodAlgorithm::Minimum, LodAlgorithm::Maximum, LodAlgorithm::MinMax, LodAlgorithm::Decimate,
  LodAlgorithm::DecimateSkipNaN, LodAlgorithm::DecimateRandom, LodAlgorithm::AllZero, LodAlgorithm::WhiteNoise,
  LodAlgorithm::MostFrequent, LodAlgorithm::MostFrequentNon0, LodAlgorithm::AverageNon0
}
 

Functions

template<typename T , typename F >
void createGenericLevelOfDetail (T *dst, const std::array< std::int64_t, 3 > &dsize, const std::array< std::int64_t, 3 > &dstride, const T *src, const std::array< std::int64_t, 3 > &ssize, const std::array< std::int64_t, 3 > &sstride, F function)
 
template<typename T >
void createGenericLevelOfDetailLoPass (T *dst, const std::array< std::int64_t, 3 > &dsize, const std::array< std::int64_t, 3 > &dstride, const T *src, const std::array< std::int64_t, 3 > &ssize, const std::array< std::int64_t, 3 > &sstride)
 Lowpass decimation vertically, simple decimation horizontally. More...
 
template<typename T >
void createLevelOfDetail (T *dst, const std::array< std::int64_t, 3 > &dsize, const std::array< std::int64_t, 3 > &dstride, const T *src, const std::array< std::int64_t, 3 > &ssize, const std::array< std::int64_t, 3 > &sstride, LodAlgorithm algorithm, const std::int64_t *hist, int bins, double minHist, double maxHist)
 
template<typename T >
void createLodT (const std::shared_ptr< DataBuffer > &result, const std::shared_ptr< const DataBuffer > &input, LodAlgorithm algorithm, const std::int64_t *hist, std::int32_t bincount, double histogram_min, double histogram_max)
 
void createLodST (const std::shared_ptr< DataBuffer > &result, const std::shared_ptr< const DataBuffer > &input, LodAlgorithm algorithm, const std::int64_t *hist, std::int32_t bincount, double histogram_min, double histogram_max)
 Main entry point for low resolution compute. More...
 
void createLodPart (const std::shared_ptr< DataBuffer > &result, const std::shared_ptr< const DataBuffer > &input, LodAlgorithm algorithm, const std::int64_t *hist, std::int32_t bincount, double histogram_min, double histogram_max, int slice_dim, std::int64_t slice_beg, std::int64_t slice_count)
 
void createLodMT (const std::shared_ptr< DataBuffer > &result, const std::shared_ptr< const DataBuffer > &input, LodAlgorithm algorithm, const std::int64_t *hist, std::int32_t bincount, double histogram_min, double histogram_max)
 Main entry point for low resolution compute. More...
 
void createLod (const std::shared_ptr< DataBuffer > &result, const std::shared_ptr< const DataBuffer > &input, LodAlgorithm algorithm, const std::int64_t *hist, std::int32_t bincount, double histogram_min, double histogram_max)
 Main entry point for low resolution compute. More...
 
OPENZGY_API bool newlogger (int priority, const std::string &str)
 
OPENZGY_API bool newlogger (int priority, const std::ios &ss)
 
template<typename T >
bool IsFiniteT (T)
 
template<>
bool IsFiniteT< float > (float value)
 
template<>
bool IsFiniteT< double > (double value)
 
template<>
bool IsFiniteT< long double > (long double value)
 
template<typename T >
bool IsNanT (T)
 
template<>
bool IsNanT< float > (float value)
 
template<>
bool IsNanT< double > (double value)
 
template<>
bool IsNanT< long double > (long double value)
 
template<typename T >
RoundAndClip (double value)
 
template<typename T >
RoundAndClip (double value, T nan)
 
template<typename T , std::size_t N>
std::array< T, N > ptr_to_array (const T *in)
 
template<typename T >
align (const T &in)
 
template<typename T , std::size_t N>
std::string array_to_string (const std::array< T, N > &a)
 
template<typename T , std::size_t N>
std::string array_to_hex (const std::array< T, N > &a)
 
template<typename T , std::size_t N>
std::string ptr_to_string (const T *a)
 
template<typename T , std::size_t N>
std::string ptr_to_hex (const T *a)
 
OPENZGY_TEST_API void byteswapV1Long (std::int64_t *ptr, size_t n=1)
 
OPENZGY_TEST_API void byteswapV1Long (std::uint64_t *ptr, size_t n=1)
 
template<typename T , typename U , int N>
std::array< T, N > array_cast (const std::array< U, N > &in)
 
void subtiling (const std::array< std::int64_t, 3 > &bricksize, std::int64_t itemsize, void *dst, const void *src, bool remove)
 
bool generalTransform (double AX0, double AY0, double AX1, double AY1, double AX2, double AY2, double BX0, double BY0, double BX1, double BY1, double BX2, double BY2, double *X, double *Y, std::size_t length)
 General coordinate conversion based on 3 control points.
 

Detailed Description

Implementation not visible to clients.

Typedef Documentation

◆ compressor_t

typedef std::function<rawdata_t(const rawdata_t&,const index3_t&)> InternalZGY::compressor_t

Function for compressing a brick.

The 3d extent of the data to be compressed is passed as a hint. The total size in the rawdata_t parameter is in bytes, while the size hint is in elements.

See also decompressor_t and compfactory_t. Currently those are only used inside class CompressFactoryImpl, so I might as well keep them private.

◆ index3_t

typedef std::array<std::int64_t,3> InternalZGY::index3_t

type equivalent to std::int64_t[3]

The implementation is a std::array.

Note: I have considered crating a new type instead of just an alias, as this would make it easier to add arithmetic and output formatters. But I really want to avoud the dependencies this would cause. See arrayops.h for some operations that work even without a separate type.

◆ rawdata_t

typedef std::pair<std::shared_ptr<const void>, std::int64_t> InternalZGY::rawdata_t

Shared data plus size. No other information.

Used to describe both inputs and outputs for the compress and decompress algorithms. Both algorithms might also need the 3d extent of the input (compress) or expected output (decompress). That information will be provided separately. The compression plug-in might choose to ignore the hints.

Enumeration Type Documentation

◆ BrickStatus

Brick status as used in the internal API only.

◆ LodAlgorithm

Possible algorithms to generate LOD bricks. This is work in progress, and not all these algorithms will get implemented. The ones that are not needed will eventually get trimmed from this enum.

Enumerator
LowPass 

Lowpass Z / decimate XY.

WeightedAverage 

Weighted averaging (depends on global stats)

Average 

Simple averaging.

Median 

Somewhat more expensive averaging.

Minimum 

Minimum value.

Maximum 

Maximum value.

MinMax 

Checkerboard of minimum and maximum values.

Decimate 

Simple decomation, use first sample.

DecimateSkipNaN 

Use first sample that is not NaN.

DecimateRandom 

Random decimation using a fixed seed. NOT IMPLEMENTED.

AllZero 

Just fill the LOD brick with zeroes.

WhiteNoise 

Fill with white noise. NOT IMPLEMENTED.

MostFrequent 

The value that occurs most frequently.

MostFrequentNon0 

The non-zero value that occurs most frequently.

AverageNon0 

Average value, but treat 0 as NaN.

◆ RawCoordType

Coordinate type codes as stored in V1 files only. The values are stored on the file, so the numbers must not be changed. Source: BrickedFileVersion.cpp. There is no corresponding enum in the API layer.

◆ RawDataType

Sample data type as stored on the file. DO NOT CHANGE except possibly adding more codes at end. In the public API this maps to SampleDataType. Source: BrickedFileVersion.cpp, MetaDataValue.h This enum is used for all versions. Note that the existing public ZGY library only recognizes SignedInt8, SignedInt16, and Float32.

◆ RawGridDefinition

Method used to define the geometry. Only FourPoint is allowed for write, and only ThreePoint (treated as FourPoint) and FourPoint supported on read. The values are stored in the file, so the numbers must not be changed. There is no corresponding enum in the API layer.

◆ RawHorizontalDimension

Horizontal dimension as seen in V2 files and later. In the public API this maps to UnitDimension. The values are stored in the file, so the numbers must not be changed. Source: PoststackSeis3dInfo.h, MetaDataValue.h, ReaderImp::getMetaData

◆ RawVerticalDimension

Vertical dimension as seen in V2 files and later. In the public API this maps to UnitDimension. The values are stored in the file, so the numbers must not be changed. Source: PoststackSeis3dInfo.h, MetaDataValue.h, ReaderImp::getMetaData

◆ UpdateMode

WORK IN PROGRESS, potential configurable behavior.

A ZGY file cannot be updated once created, but individual bricks might be written to more than once while the file is still open for create.

Updating a brick might cause loss of quality if the update was made as part of a read/modify/write cycle. It might also cause space to be wasted in the file since ZGY does not try to recycle freed bricks. For this reason the application should explicitly indicate that it accepts the loss of quality and/or leakage.

Kinds of leakage:

  • Brick to be overwritten is in a closed segment. This is expected to be rare, and only relevant for cloud storage.
  • Brick to be overwritten and/or new brick is compressed and the new data is smaller. Leaks the size difference, although for implementation reasons we might want to leak the entire old brick ("Pedantic" mode).
  • Brick to be overwritten and/or new brick is compressed and the new data is larger. Leaks the old brick.

The default is "Always" for uncompressed local files and "Constant" otherwise.

It is fairly safe to set an uncompressed cloud file to "Always" but there are some scenarios where very small regions are written to a large file where this might cause much leakage. So the caller needs to confirm he knows what he is doing.

Compressed files should only be set to "Always" in very special cases or in unit tests. The potential leakage is much larger, as is the problem of multiple compress and decompress cycles causing noise.

Function Documentation

◆ align()

template<typename T >
T InternalZGY::align ( const T &  in)

Return the input scalar in such a way that &in is allowed to be misaligned with respect to T. Note that I am not sure this is good enough. A simple assignment instead of the memcpy will trigger undefined behavior. A decent compiler should optimize away the memcpy but also make sure that it doesn't use e.g. not try to use e.g. SSE instructions that require alignment. Worry: By defining the input argument as T&, will the compiler already at that point make up its mind that in must be aligned? https://pzemtsov.github.io/2016/11/06/bug-story-alignment-on-x86.html

◆ array_to_hex()

template<typename T , std::size_t N>
std::string InternalZGY::array_to_hex ( const std::array< T, N > &  a)

For debugging, format a std::array of a numeric type into a hex string.

◆ array_to_string()

template<typename T , std::size_t N>
std::string InternalZGY::array_to_string ( const std::array< T, N > &  a)

For debugging, works as std::to_string but takes care to also output std::int8_t and std::uint8_t as numbers, even though those types are probably typedef'd to signed/unsigned char.

◆ byteswapV1Long()

void InternalZGY::byteswapV1Long ( std::int64_t *  ptr,
size_t  n = 1 
)

Convert a 64-bit integer stored on disk as vcs_uint64 to the in-memory representation or back. Class vcs_uint64 consisted of two uint32_type members representing the high and low (in that order) 32-bits of a 64-bit unsigned integer. The two halves were stored little-endian on disk.

This method includes conversion between big and little endian if needed, byte swapping each of the 32-bit halves separately. Caveat, that functonality has not been properly tested.

The format was used by:

  • VCS (compressed ZGY) version 1 - 13
  • VBS (uncompressed ZGY) version 1
  • VCO (compressed object file) version 1

Currently only VBS 1 is a concern for this code. There are 64 bit ints in the alpha- and brick lookup tables and in the offset headers.

◆ createGenericLevelOfDetail()

template<typename T , typename F >
void InternalZGY::createGenericLevelOfDetail ( T *  dst,
const std::array< std::int64_t, 3 > &  dsize,
const std::array< std::int64_t, 3 > &  dstride,
const T *  src,
const std::array< std::int64_t, 3 > &  ssize,
const std::array< std::int64_t, 3 > &  sstride,
function 
)

Generic LOD calculation that can be used for all algorithms where the resulting sample depends only on the 8 surrounding samples in the source brick. I.e. currently everything except the lowpass algorithm that needs a window of size 10. The actual algorithm to be used is passed as a functor. If any calculation needs to be done up front, that can be handled by the functor's constructor.

◆ createGenericLevelOfDetailLoPass()

template<typename T >
void InternalZGY::createGenericLevelOfDetailLoPass ( T *  dst,
const std::array< std::int64_t, 3 > &  dsize,
const std::array< std::int64_t, 3 > &  dstride,
const T *  src,
const std::array< std::int64_t, 3 > &  ssize,
const std::array< std::int64_t, 3 > &  sstride 
)

Lowpass decimation vertically, simple decimation horizontally.

Unlike the other algorithms this one needs full traces as input. Or at least prefers full traces, to avoid brick artifacts vertically.

◆ createLevelOfDetail()

template<typename T >
void InternalZGY::createLevelOfDetail ( T *  dst,
const std::array< std::int64_t, 3 > &  dsize,
const std::array< std::int64_t, 3 > &  dstride,
const T *  src,
const std::array< std::int64_t, 3 > &  ssize,
const std::array< std::int64_t, 3 > &  sstride,
LodAlgorithm  algorithm,
const std::int64_t *  hist,
int  bins,
double  minHist,
double  maxHist 
)

Create a single LOD brick based on the data from one LOD level below. The valuetype of the source and target must be the same, but can be almost any scalar type.

Histogram information is passed in for use by some of the algorithms. The histogram should be in "storage" units. That only affects its limits though. TODO-Worry make sure these are set correctly. The old accessor assumed that for integral data the limits were simply the entire range.

When doing lowpass filtering of integral data, the actual calculation is done using doubles. We need to clip the result to the range of the data value type to prevent overflows, since the lowpass filter can give a result slightly outside the input range.

When doing lowpass filtering of float data there will be no clipping. Some samples might end up slightly outside the actual value range of the input data. Note behavior change: The old accessor did some clipping to avoid that case. Which just added to the confusion because the range it clipped to might be inaccurate.

◆ createLod()

void OPENZGY_TEST_API InternalZGY::createLod ( const std::shared_ptr< DataBuffer > &  result,
const std::shared_ptr< const DataBuffer > &  input,
LodAlgorithm  algorithm,
const std::int64_t *  hist,
std::int32_t  bincount,
double  histogram_min,
double  histogram_max 
)

Main entry point for low resolution compute.

Create a single low resolution brick 1/8th the size of the input. Decides whether to enable multi-threading or not.

◆ createLodMT()

void OPENZGY_TEST_API InternalZGY::createLodMT ( const std::shared_ptr< DataBuffer > &  result,
const std::shared_ptr< const DataBuffer > &  input,
LodAlgorithm  algorithm,
const std::int64_t *  hist,
std::int32_t  bincount,
double  histogram_min,
double  histogram_max 
)

Main entry point for low resolution compute.

Create a single low resolution brick 1/8th the size of the input. This is the multi-threaded version.

Caveat: If parallelizing is also done at a higher level then consider omp_set_max_active_levels(), especially if the higher level might only be able to use 2 or 4 threads.

One argument for parallelizing on a higher level instead is that we might then be able to read and compute at the same time. N/A for local file access because buffer cache prefectch can give us that automatically. I think.

TODO-Low fall back to single threaded if the input is small (e.g. less than 16 slices or less than 64^3 samples) or if the caller asks for cheaper algorithms. Low priority because those cases are (a) rare and (b) should run fast anyway, even if single thread might give a slight improvement.

Using a simple "copy" app between two local ssd files I measured the time for lod compute as 4% of finalize time or 2% of total time with 8 threads. Compared to 23% / 13% for a single thread. So the MT case had a 10% overall speedup on this test.

Switching to the much cheaper "Decimate" algorithm (just pick one of every 8 samples) then even in the single threaded case the algorithm only accounts for < 1% so there is not much to gain.

Algorithm(s) used for Onnia Time
Decimate 8 sec
Average 37 sec
LowPass 72 sec
WeightedAverage 732 sec
Decimate,WeightedAverage 102 sec
LowPass,Decimate 64 sec
LowPass,WeightedAverage 159 sec

◆ createLodPart()

void InternalZGY::createLodPart ( const std::shared_ptr< DataBuffer > &  result,
const std::shared_ptr< const DataBuffer > &  input,
LodAlgorithm  algorithm,
const std::int64_t *  hist,
std::int32_t  bincount,
double  histogram_min,
double  histogram_max,
int  slice_dim,
std::int64_t  slice_beg,
std::int64_t  slice_count 
)

Run the low resolution compute on just a part of the provided data buffer. The part will be one of more slices in the slowest changing direction. If passing the last 3 parameters as "entire survey" then this is equivalent to calling createLodST() directly.

◆ createLodST()

void OPENZGY_TEST_API InternalZGY::createLodST ( const std::shared_ptr< DataBuffer > &  result,
const std::shared_ptr< const DataBuffer > &  input,
LodAlgorithm  algorithm,
const std::int64_t *  hist,
std::int32_t  bincount,
double  histogram_min,
double  histogram_max 
)

Main entry point for low resolution compute.

Create a single low resolution brick 1/8th the size of the input. This is the single threaded version.

◆ createLodT()

template<typename T >
void InternalZGY::createLodT ( const std::shared_ptr< DataBuffer > &  result,
const std::shared_ptr< const DataBuffer > &  input,
LodAlgorithm  algorithm,
const std::int64_t *  hist,
std::int32_t  bincount,
double  histogram_min,
double  histogram_max 
)

New version with "modernized" types. Not sure if it belongs in this file or higher up.

◆ IsFiniteT()

template<typename T >
bool InternalZGY::IsFiniteT ( )

IsFiniteT uses template magic to avoid having to test integral types.

◆ IsNanT()

template<typename T >
bool InternalZGY::IsNanT ( )

IsNanT uses template magic to avoid having to test integral types.

◆ ptr_to_array()

template<typename T , std::size_t N>
std::array<T, N> InternalZGY::ptr_to_array ( const T *  in)

Convert a raw C pointer, possibly misaligned, to a safer std::array. Callers will need to specify both template parameters. In theory the compiler should be able to deduce T, but I haven't found a way to do this while still explicitly providing N.

◆ ptr_to_hex()

template<typename T , std::size_t N>
std::string InternalZGY::ptr_to_hex ( const T *  a)

For debugging, format a raw pointer to a numeric type into a hex string. Caller needs to explicitly provide both template parameters.

◆ ptr_to_string()

template<typename T , std::size_t N>
std::string InternalZGY::ptr_to_string ( const T *  a)

For debugging, format a raw pointer to a numeric type into a string. Caller needs to explicitly provide both template parameters.

◆ RoundAndClip() [1/2]

template<typename T >
T InternalZGY::RoundAndClip ( double  value)

Cast a double to another type. If the target type is floating point, this is a simple cast. If the target type is integral the result is rounded to nearest and clipped to the target's value range. If you supply a second argument, NaN in the input is replaced with this value. plus or minus infinite are still clipped to the target range. If you do not supply a second argument, NaN input will result in an undefined return value. It probably ends up being 0x80000000 for signed/unsigned int and 0 for narrowed integral types, but the caller should not depend on this.

◆ RoundAndClip() [2/2]

template<typename T >
T InternalZGY::RoundAndClip ( double  value,
nan 
)

Cast a double to another type, including substituting NaN with a value supplied by the caller if and only if the target is integral.

◆ subtiling()

void InternalZGY::subtiling ( const std::array< std::int64_t, 3 > &  bricksize,
std::int64_t  itemsize,
void *  dst,
const void *  src,
bool  remove 
)

Convert a single brick from subtiled to standard (if remove=true) or back.