Commit 04e3d865 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Remove use of std::string in api's

parent 0d42175f
......@@ -266,9 +266,6 @@ bool isDimensionInGroup(DimensionGroup dimensionGroup, int32_t dimension)
}
}
/////////////////////////////////////////////////////////////////////////////
// DimensionGroup::GetDimensionality
int32_t getDimensionality(DimensionGroup dimensionGroup)
{
switch(dimensionGroup)
......@@ -354,9 +351,6 @@ int32_t getDimensionality(DimensionGroup dimensionGroup)
}
}
/////////////////////////////////////////////////////////////////////////////
// DimensionGroup::GetDimension
int32_t getDimension(DimensionGroup dimensionGroup, int32_t indexInGroup)
{
assert(dimensionGroup >= 0 && dimensionGroup < DimensionGroup_Max);
......
......@@ -110,7 +110,7 @@ public:
}
// Methods
uint64_t GetCombinedHash() const { return m_combinedHash; }
uint64_t getCombinedHash() const { return m_combinedHash; }
template<typename T>
HashCombiner& add(const T& tValue)
......
......@@ -18,6 +18,8 @@
#ifndef VOLUMEDATAAXISDESCRIPTOR_H
#define VOLUMEDATAAXISDESCRIPTOR_H
#include <Math/Range.h>
#include <cmath>
#include <string>
......@@ -26,38 +28,40 @@ namespace OpenVDS
class VolumeDataAxisDescriptor
{
int m_numSamples;
std::string m_name;
std::string m_unit;
float m_coordinateMin;
float m_coordinateMax;
const char *m_name;
const char *m_unit;
Range<float> m_coordinateRange;
public:
VolumeDataAxisDescriptor() : m_numSamples(-1), m_name(0), m_unit(0), m_coordinateMin(0.0f), m_coordinateMax(0.0f) {}
VolumeDataAxisDescriptor() : m_numSamples(-1), m_name(nullptr), m_unit(nullptr), m_coordinateRange({0.0f, 0.0f}) {}
/// \param numSamples the number of samples along this axis
/// \param pName the name of this axis
/// \param pUnit the unit for this axis
/// \param coordinateMin the minumum coordinate for this axis
/// \param coordinateMax the maximum coordinate for this axis
VolumeDataAxisDescriptor(int numSamples, const std::string &pName, const std::string &pUnit, float coordinateMin, float coordinateMax)
: m_numSamples(numSamples), m_name(pName), m_unit(pUnit), m_coordinateMin(coordinateMin), m_coordinateMax(coordinateMax) {}
VolumeDataAxisDescriptor(int numSamples, const char *name, const char *unit, float coordinateMin, float coordinateMax)
: m_numSamples(numSamples), m_name(name), m_unit(unit), m_coordinateRange({coordinateMin, coordinateMax}) {}
int getNumSamples() const { return m_numSamples; }
const std::string &getName() const { return m_name; }
const std::string &getUnit() const { return m_unit; }
float getCoordinateMin() const { return m_coordinateMin; }
float getCoordinateMax() const { return m_coordinateMax; }
float getCoordinateStep() const { return (m_numSamples > 1) ? ((m_coordinateMax - m_coordinateMin) / (m_numSamples - 1)) : 0; }
VolumeDataAxisDescriptor(int numSamples, const char *name, const char *unit, const Range<float> &coordinateRange)
: m_numSamples(numSamples), m_name(name), m_unit(unit), m_coordinateRange(coordinateRange) {}
int getNumSamples() const { return m_numSamples; }
const char *getName() const { return m_name; }
const char *getUnit() const { return m_unit; }
float getCoordinateMin() const { return m_coordinateRange.min; }
float getCoordinateMax() const { return m_coordinateRange.max; }
const Range<float> &getCoordinateRange() const { return m_coordinateRange; }
float getCoordinateStep() const { return (m_numSamples > 1) ? ((m_coordinateRange.max - m_coordinateRange.min) / (m_numSamples - 1)) : 0; }
/// Convert a sample index on this axis to a coordinate value
/// \param sampleIndex the sample index to convert
/// \return the coordinate
float sampleIndexToCoordinate(int sampleIndex) { return m_coordinateMin + sampleIndex * getCoordinateStep(); }
float sampleIndexToCoordinate(int sampleIndex) { return m_coordinateRange.min + sampleIndex * getCoordinateStep(); }
/// Convert a coordinate to a sample index (rounding to the closest index)
/// \param coordinate the coordinate to convert
/// \return the sample index
int coordinateToSampleIndex(float coordinate) { return (coordinate == m_coordinateMin) ? 0 : (int)floorf(((coordinate - m_coordinateMin) / (m_coordinateMax - m_coordinateMin)) * (m_numSamples - 1) + 0.5f); }
int coordinateToSampleIndex(float coordinate) { return (coordinate == m_coordinateRange.min) ? 0 : (int)floorf(((coordinate - m_coordinateRange.min) / (m_coordinateRange.max - m_coordinateRange.min)) * (m_numSamples - 1) + 0.5f); }
};
}
#endif //VOLUMEDATAAXISDESCRIPTOR_H
......
......@@ -172,8 +172,8 @@ public:
/// \param noValue the No Value for this channel
/// \param integerScale the scale to use for integer types
/// \param integerOffset the offset to use for integer types
VolumeDataChannelDescriptor(Format format, Components components, const char *pName, const char *pUnit, float valueRangeMin, float valueRangeMax, enum VolumeDataMapping mapping, int mappedValueCount, enum Flags flags, float noValue, float integerScale, float integerOffset)
: m_format(format), m_components(components), m_name(pName), m_unit(pUnit), m_valueRange({valueRangeMin, valueRangeMax}), m_mapping(mapping), m_mappedValueCount(mappedValueCount), m_flags(flags), m_useNoValue(true), m_noValue(noValue), m_integerScale(integerScale), m_integerOffset(integerOffset) {}
VolumeDataChannelDescriptor(Format format, Components components, const char *name, const char *unit, float valueRangeMin, float valueRangeMax, enum VolumeDataMapping mapping, int mappedValueCount, enum Flags flags, float noValue, float integerScale, float integerOffset)
: m_format(format), m_components(components), m_name(name), m_unit(unit), m_valueRange({valueRangeMin, valueRangeMax}), m_mapping(mapping), m_mappedValueCount(mappedValueCount), m_flags(flags), m_useNoValue(true), m_noValue(noValue), m_integerScale(integerScale), m_integerOffset(integerOffset) {}
Format getFormat() const { return m_format; }
Components getComponents() const { return m_components; }
......@@ -181,13 +181,13 @@ public:
bool isRenderable() const { return !(m_flags & NotRenderable); }
bool isAllowLossyCompression() const { return !(m_flags & NoLossyCompression) && !isDiscrete(); }
bool isUseZipForLosslessCompression() const { return (m_flags & NoLossyCompressionUseZip) == NoLossyCompressionUseZip; }
const char *getName() const { return m_name; }
const char *getUnit() const { return m_unit; }
const char *getName() const { return m_name; }
const char *getUnit() const { return m_unit; }
const Range<float> &getValueRange() const { return m_valueRange; }
float getValueRangeMin() const { return m_valueRange.min; }
float getValueRangeMax() const { return m_valueRange.max; }
VolumeDataMapping getMapping() const { return m_mapping; }
VolumeDataMapping getMapping() const { return m_mapping; }
int getMappedValueCount() const { return m_mappedValueCount; }
bool isUseNoValue() const { return m_useNoValue; }
......
......@@ -89,13 +89,13 @@ int32_t VolumeDataLayer::getMappedValueCount() const
void VolumeDataLayer::getChunkIndexArrayFromVoxel(const IndexArray& voxel, IndexArray& chunk) const
{
//const VolumeDataChannelMapping *volumeDataChannelMapping = m_volumeDataLayout->GetVolumeDataChannelMapping(GetChannelIndex());
//const VolumeDataChannelMapping *volumeDataChannelMapping = m_volumeDataLayout->getVolumeDataChannelMapping(getChannelIndex());
for(int32_t iDimension = 0; iDimension < array_size(chunk); iDimension++)
{
//if(volumeDataChannelMapping)
//{
// chunk[iDimension] = volumeDataChannelMapping->GetMappedChunkIndexFromVoxel(GetPrimaryChannelLayer(), voxel[iDimension], iDimension);
// chunk[iDimension] = volumeDataChannelMapping->getMappedChunkIndexFromVoxel(getPrimaryChannelLayer(), voxel[iDimension], iDimension);
//}
//else
//{
......@@ -107,7 +107,7 @@ void VolumeDataLayer::getChunkIndexArrayFromVoxel(const IndexArray& voxel, Index
int64_t
VolumeDataLayer::getChunkIndexFromNDPos(const NDPos &ndPos) const
{
//const VolumeDataChannelMapping *volumeDataChannelMapping = m_volumeDataLayout->GetVolumeDataChannelMapping(GetChannelIndex());
//const VolumeDataChannelMapping *volumeDataChannelMapping = m_volumeDataLayout->getVolumeDataChannelMapping(getChannelIndex());
IndexArray chunk;
......@@ -115,7 +115,7 @@ VolumeDataLayer::getChunkIndexFromNDPos(const NDPos &ndPos) const
{
//if(volumeDataChannelMapping)
//{
// chunk[iDimension] = volumeDataChannelMapping->GetMappedChunkIndexFromVoxel(GetPrimaryChannelLayer(), (int32_t)floorf(ndPos.data[iDimension]), iDimension);
// chunk[iDimension] = volumeDataChannelMapping->getMappedChunkIndexFromVoxel(getPrimaryChannelLayer(), (int32_t)floorf(ndPos.data[iDimension]), iDimension);
//}
//else
//{
......@@ -148,7 +148,7 @@ const VolumeDataLayer * VolumeDataLayer::getLayerToRemapFrom() const
return m_remapFromLayer;
}
//VolumeDataLayer::ProduceMethod VolumeDataLayer::GetProduceMethod() const
//VolumeDataLayer::ProduceMethod VolumeDataLayer::getProduceMethod() const
//{
// if(m_channel != 0)
// {
......@@ -230,7 +230,7 @@ uint64_t VolumeDataLayer::getFormatHash(VolumeDataChannelDescriptor::Format actu
hashCombiner.add(replacementNoValue);
}
return hashCombiner.GetCombinedHash();
return hashCombiner.getCombinedHash();
}
bool VolumeDataLayer::isUseNoValue() const
......@@ -285,7 +285,7 @@ CompressionMethod VolumeDataLayer::getEffectiveCompressionMethod() const
float VolumeDataLayer::getEffectiveCompressionTolerance() const
{
auto &channelDescriptor = m_volumeDataLayout->getVolumeDataChannelDescriptor(m_channel);
//return m_volumeDataLayout->GetVolumeDataChannelDescriptor(m_channel).GetEffectiveCompressionTolerance(m_volumeDataLayout->m_compressionTolerance, GetLod());
//return m_volumeDataLayout->getVolumeDataChannelDescriptor(m_channel).getEffectiveCompressionTolerance(m_volumeDataLayout->m_compressionTolerance, getLod());
if(!channelDescriptor.isAllowLossyCompression())
{
return 0.0f;
......
......@@ -154,7 +154,7 @@ VolumeDataLayer *VolumeDataLayout::getTopLayer(DimensionGroup dimensionGroup, in
return volumeDataLayer;
}
bool VolumeDataLayout::isChannelAvailable(const std::string &channelName) const
bool VolumeDataLayout::isChannelAvailable(const char *channelName) const
{
int32_t nChannels = getChannelCount();
......@@ -166,7 +166,7 @@ bool VolumeDataLayout::isChannelAvailable(const std::string &channelName) const
return false;
}
int32_t VolumeDataLayout::getChannelIndex(const std::string& channelName) const
int32_t VolumeDataLayout::getChannelIndex(const char *channelName) const
{
int32_t nChannels = getChannelCount();
......@@ -224,10 +224,9 @@ VolumeDataAxisDescriptor VolumeDataLayout::getAxisDescriptor(int32_t dimension)
{
assert(dimension >= 0 && dimension < m_dimensionality);
return VolumeDataAxisDescriptor(getDimensionNumSamples(dimension),
GetDimensionName(dimension),
GetDimensionUnit(dimension),
getDimensionRange(dimension).min,
getDimensionRange(dimension).max);
getDimensionName(dimension),
getDimensionUnit(dimension),
getDimensionRange(dimension));
}
VolumeDataMapping VolumeDataLayout::getChannelMapping(int32_t channel) const
......@@ -258,13 +257,13 @@ int VolumeDataLayout::getDimensionNumSamples(int32_t dimension) const
return m_dimensionNumSamples[dimension];
}
const std::string& VolumeDataLayout::GetDimensionName(int32_t dimension) const
const char *VolumeDataLayout::getDimensionName(int32_t dimension) const
{
assert(dimension >= 0 && dimension < array_size(m_dimensionName));
return m_dimensionName[dimension];
}
const std::string& VolumeDataLayout::GetDimensionUnit(int32_t dimension) const
const char *VolumeDataLayout::getDimensionUnit(int32_t dimension) const
{
assert(dimension >= 0 && dimension < array_size(m_dimensionUnit));
return m_dimensionUnit[dimension];
......
......@@ -51,8 +51,8 @@ private:
bool m_isZipLosslessChannels;
int32_t m_waveletAdaptiveLoadLevel;
IndexArray m_dimensionNumSamples;
std::string m_dimensionName[Dimensionality_Max];
std::string m_dimensionUnit[Dimensionality_Max];
const char *m_dimensionName[Dimensionality_Max];
const char *m_dimensionUnit[Dimensionality_Max];
Range<float> m_dimensionRange[Dimensionality_Max];
int32_t m_fullResolutionDimension;
......@@ -102,10 +102,10 @@ public:
const VolumeDataChannelDescriptor &getVolumeDataChannelDescriptor(int32_t channel) const { return m_volumeDataChannelDescriptor[channel]; }
//REMOVE VIRTUAL?
// // Implementation of VolumeDataLayout interface
// Implementation of VolumeDataLayout interface
virtual int32_t getChannelCount() const { return int32_t(m_volumeDataChannelDescriptor.size()); }
virtual bool isChannelAvailable(const std::string &channelName) const;
virtual int32_t getChannelIndex(const std::string &channelName) const;
virtual bool isChannelAvailable(const char *channelName) const;
virtual int32_t getChannelIndex(const char *channelName) const;
virtual VolumeDataChannelDescriptor getChannelDescriptor(int32_t channel) const;
virtual int32_t getDimensionality() const { return m_dimensionality; }
......@@ -116,12 +116,12 @@ public:
virtual VolumeDataChannelDescriptor::Components getChannelComponents(int32_t channel) const { assert(channel >= 0 && channel < getChannelCount()); return m_volumeDataChannelDescriptor[channel].getComponents(); }
virtual const std::string &getChannelName(int32_t channel) const { assert(channel >= 0 && channel < getChannelCount()); return m_volumeDataChannelDescriptor[channel].getName(); }
virtual const const char *getChannelName(int32_t channel) const { assert(channel >= 0 && channel < getChannelCount()); return m_volumeDataChannelDescriptor[channel].getName(); }
virtual float getChannelValueRangeMin(int32_t channel) const { return getChannelValueRange(channel).min; }
virtual float getChannelValueRangeMax(int32_t channel) const { return getChannelValueRange(channel).max; }
virtual const std::string &getChannelUnit(int32_t channel) const { assert(channel >= 0 && channel < getChannelCount()); return m_volumeDataChannelDescriptor[channel].getUnit(); }
virtual const const char *getChannelUnit(int32_t channel) const { assert(channel >= 0 && channel < getChannelCount()); return m_volumeDataChannelDescriptor[channel].getUnit(); }
virtual bool isChannelDiscrete(int32_t channel) const { assert(channel >= 0 && channel < getChannelCount()); return m_volumeDataChannelDescriptor[channel].isDiscrete(); }
virtual bool isChannelRenderable(int32_t channel) const { assert(channel >= 0 && channel < getChannelCount()); return m_volumeDataChannelDescriptor[channel].isRenderable(); }
......@@ -134,9 +134,9 @@ public:
// These convenience functions provide access to the individual elements of the axis descriptors
virtual int getDimensionNumSamples(int32_t dimension) const;
virtual const std::string &GetDimensionName(int32_t dimension) const;
virtual const char *getDimensionName(int32_t dimension) const;
virtual const std::string &GetDimensionUnit(int32_t dimension) const;
virtual const char *getDimensionUnit(int32_t dimension) const;
virtual float getDimensionMin(int32_t dimension) const { return getDimensionRange(dimension).min; }
virtual float getDimensionMax(int32_t dimension) const { return getDimensionRange(dimension).max; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment