|
OpenZGY/C++ API and Internals (ALPHA)
Access seismic data stored in ZGY format.
|
Public Types | |
| enum | { ndim = NDim } |
| typedef T | value_type |
| typedef DataBufferNd< T, NDim > | self_type |
| typedef std::array< std::int64_t, NDim > | ndsize_t |
Public Types inherited from InternalZGY::DataBuffer | |
| enum | flags_t { C_ORDERING =1, CONTIGUOUS =2, POSITIVE_STRIDE =4, DEGENERATE =8 } |
Public Member Functions | |
| DataBufferNd (const self_type &)=delete | |
| self_type & | operator= (const self_type &)=delete |
| DataBufferNd (T scalar, const std::array< std::int64_t, NDim > &size) | |
| DataBufferNd (const std::array< std::int64_t, NDim > &size) | |
| DataBufferNd (const std::array< std::int64_t, NDim > &size, const std::array< std::int64_t, NDim > &stride) | |
| DataBufferNd (const std::shared_ptr< T > &data, const std::array< std::int64_t, NDim > &size) | |
| DataBufferNd (const std::shared_ptr< T > &data, const std::array< std::int64_t, NDim > &size, const std::array< std::int64_t, NDim > &stride) | |
| T * | data () |
| const T * | data () const |
| T | scalarValue () const |
| virtual bool | ownsdata () const |
| bool | isScalar () const override |
| bool | isAllSame (const std::int64_t *used_in) const override |
| double | scalarAsDouble () const override |
| RawDataType | datatype () const override |
| void | fill (double value) override |
| Set all samples to the same value. More... | |
| void | clear () override |
| std::pair< double, double > | range () const override |
| std::uint32_t | layout () const override |
| bool | is_cstride () const override |
| void | check_cstride () const override |
| std::string | toString () const override |
| std::shared_ptr< void > | voidData () override |
| std::shared_ptr< const void > | voidData () const override |
| bool | contiguous () const override |
| std::int64_t | allocsize () const override |
| std::int64_t | totalsize () const override |
| std::int64_t | itemsize () const override |
| const std::int64_t * | sizeptr () const override |
| const std::int64_t * | strideptr () const override |
| std::array< std::int64_t, 3 > | size3d () const override |
| std::array< std::int64_t, 3 > | stride3d () const override |
| const ndsize_t & | safesize () const |
| const ndsize_t & | safestride () const |
| std::shared_ptr< DataBuffer > | clone () const |
| std::shared_ptr< DataBuffer > | scaleToFloat (const std::array< double, 2 > &) override |
| std::shared_ptr< DataBuffer > | scaleToStorage (const std::array< double, 2 > &, RawDataType) override |
| std::shared_ptr< DataBuffer > | slice1 (int dim, std::int64_t start, std::int64_t size) const override |
| Make a shallow view over the buffer, showing only part of the input. More... | |
| std::shared_ptr< self_type > | slice (const ndsize_t &neworig, const ndsize_t &newsize) const |
| Make a shallow view over the buffer, showing only part of the input. More... | |
| void | copyFrom (const DataBuffer *src, const std::int64_t *srcorig, const std::int64_t *dstorig, const std::int64_t *cpyorig, const std::int64_t *cpysize) |
Public Member Functions inherited from InternalZGY::DataBuffer | |
| DataBuffer (const DataBuffer &)=delete | |
| DataBuffer & | operator= (const DataBuffer &)=delete |
Static Public Member Functions | |
| static void | copySubset (const ndsize_t &srcorig, const self_type &src, const ndsize_t &dstorig, self_type &dst, const ndsize_t &cpyorig, const ndsize_t &cpysize) |
| static void | copySubset (const ndsize_t &srcorig, const self_type &src, const ndsize_t &dstorig, self_type &dst) |
| static std::shared_ptr< DataBuffer > | s_scaleToFloat (const DataBuffer *, const std::array< double, 2 > &) |
| static std::shared_ptr< DataBuffer > | s_scaleFromFloat (const DataBuffer *, const std::array< double, 2 > &) |
Static Public Member Functions inherited from InternalZGY::DataBuffer | |
| static std::shared_ptr< DataBuffer > | makeDataBuffer3d (void *raw, std::int64_t nbytes, const std::array< std::int64_t, 3 > &size, RawDataType dtype) |
|
overridevirtual |
Make the buffer empty. Size and stride are unchanged but the data will be nullptr. This will cause an access violation if trying to read or write data. The reason this is useful is that _data might point to something that is not reference counted by our smart pointer. The pointer's deleter is then a no-op. clear() should be called if we can no longer trust that the pointer is valid. A reproducible null pointer exception is way better than random crashes.
Implements InternalZGY::DataBuffer.
|
virtual |
Make a deep copy of the buffer. Works both for scalars and normal buffers. TODO-Low: consider making the buffer contiguous.
Implements InternalZGY::DataBuffer.
|
virtual |
Corresponds to openzgy.impl._partialCopy(). To make templates work better the C++ version is an instance method with 'this' as destination.
Implements InternalZGY::DataBuffer.
|
overridevirtual |
Set all samples to the same value.
The value is passed as a float and will be cast to the correct type. There is NO check for overflow.
Some optimizing is attempted because gprof claims that (a) calling this function amounts to 50% of the read overhead, and (b) memset, if possible, would reduce that time significantly. I suspect that both of those numbers are false. An ad-hoc Timer reports 10% in both cases. But just in case I am wrong I have added the optimization.
Using memset is possible if the value to be set is zero (the common case for float cubes) and if the sample size is 1 (all int8 cubes). Int16 cubes are less likely to benefit.
Implements InternalZGY::DataBuffer.
|
static |
See s_scaleToFloat() for details.
|
static |
Copy the input DataBuffer into a newly allocated buffer of float. The input is assumed to have been read from a ZGY file, so this function will also apply the storage to float transform.
If the buffer is already floating point then it needs neither type conversion nor scaling and the function will return an empty pointer. Note that it does not return its input argument, because the input is a plain pointer and I don't want to mess with std::enable_shared_from_this.
Note that both s_scaleToFloat and s_scaleFromFloat are private static methods that are templated on the integral type. This means that s_scaleToFloat is templated on the input type and s_scaleFromFloat is templated on the desired target type. The public interface is in the virtual scaleToFloat() and scaleToStorage() methods.
If the buffer is non contiguous the contents of the padding area is unspecified. It might be garbage or values converted from the input. This violates the principle of least surprise but is likely harmless.
TODO-Low: Should I try to combine the type conversion and scaling done here with the functionality of copySubset? This might allow skipping one temporary buffer but I don't know how easy it will be for the bulk access to make use of it.
|
overridevirtual |
Convert DataBufferNd<T,N> to DataBufferNd<float,N>, hiding leaf types.
Implements InternalZGY::DataBuffer.
|
overridevirtual |
Convert DataBufferNd<float,N> to DataBufferNd<T,N>, hiding leaf types.
Implements InternalZGY::DataBuffer.
|
overridevirtual |
Return the size of the buffer, assuming it is 3d. Which it almost always is. As a code smell this suggests that DataBuffer maybe shouldn't have been templated on NDim in the first place. Or have NDim as a regular varable. If fewer than 3 dimensions exist then the first index or indices are treated as size=1, stride=0. If more then 3 dimensions only the last 3 will be returned. Which is probably not very useful.
Implements InternalZGY::DataBuffer.
|
overridevirtual |
Return the size of the buffer, as a pointer to the first dimension. This is unsafe since the compiler cannot check the length. This function is meant for internal use in this file. Used by CopySubset and CopySize. TODO-Low consider making those friends so that this method can be declared private or inlined.
Implements InternalZGY::DataBuffer.
| std::shared_ptr< DataBufferNd< T, NDim > > InternalZGY::DataBufferNd< T, NDim >::slice | ( | const ndsize_t & | neworig, |
| const ndsize_t & | newsize | ||
| ) | const |
Make a shallow view over the buffer, showing only part of the input.
If the input is contiguous and the slicing is done only on the slowest varying dimension then the result will be contiguous as well.
TODO-Worry: Much of the code using class DataBuffer assumes contiguous buffers without stating this explicitly.
|
overridevirtual |
Make a shallow view over the buffer, showing only part of the input.
If the input is contiguous and the slicing is done only on the slowest varying dimension then the result will be contiguous as well.
TODO-Worry: Much of the code using class DataBuffer assumes contiguous buffers without stating this explicitly.
The slice1() function signature allows just one dimension to change at a time. This corresponds to how the method is used in OpenZGY. It also makes it possible to declare the method virtual in class DataBuffer. Yet another place I regret templating on NDim.
Implements InternalZGY::DataBuffer.
|
overridevirtual |
Return the layout of the buffer, assuming it is 3d. See size3d().
Implements InternalZGY::DataBuffer.
|
overridevirtual |
Return the layout of the buffer, assuming it is 3d. See sizeptr().
Implements InternalZGY::DataBuffer.
1.8.17