Commit eef2c317 authored by Morten Ofstad's avatar Morten Ofstad
Browse files

Added complete documentation for VolumeDataAxisDescriptor. Got rid of the...

Added complete documentation for VolumeDataAxisDescriptor. Got rid of the CoordinateRange since it's not really a range (i.e. Max can be smaller than Min) and documented this better. Fixed documentation for VolumeDataAccessManager::GetVolumeDataLayout().
parent 94d95535
...@@ -83,9 +83,6 @@ public: ...@@ -83,9 +83,6 @@ public:
/// <summary> /// <summary>
/// Get the VolumeDataLayout object for a VDS. /// Get the VolumeDataLayout object for a VDS.
/// </summary> /// </summary>
/// <param name="cVDS">
/// The VDS object to get the layout for.
/// </param>
/// <returns> /// <returns>
/// The VolumeDataLayout object associated with the VDS or NULL if there is no valid VolumeDataLayout. /// The VolumeDataLayout object associated with the VDS or NULL if there is no valid VolumeDataLayout.
/// </returns> /// </returns>
......
...@@ -25,43 +25,113 @@ ...@@ -25,43 +25,113 @@
namespace OpenVDS namespace OpenVDS
{ {
/// <summary>
/// Describes the number of samples, name, unit and coordinates (annotation) of an axis (dimension) of the volume
/// </summary>
class VolumeDataAxisDescriptor class VolumeDataAxisDescriptor
{ {
int m_numSamples; int m_numSamples;
const char *m_name; const char *m_name;
const char *m_unit; const char *m_unit;
FloatRange m_coordinateRange; float m_coordinateMin;
float m_coordinateMax;
public: public:
VolumeDataAxisDescriptor() : m_numSamples(-1), m_name(nullptr), m_unit(nullptr), m_coordinateRange({0.0f, 0.0f}) {} /// <summary>
/// Default constructor
/// </summary>
VolumeDataAxisDescriptor() : m_numSamples(), m_name(), m_unit(), m_coordinateMin(), m_coordinateMax() {}
/// \param numSamples the number of samples along this axis /// <summary>
/// \param pName the name of this axis /// Constructor
/// \param pUnit the unit for this axis /// </summary>
/// \param coordinateMin the minumum coordinate for this axis /// <param name="numSamples">
/// \param coordinateMax the maximum coordinate for this axis /// The number of samples along this axis
/// </param>
/// <param name="name">
/// The name of this axis
/// </param>
/// <param name="unit">
/// The unit of the coordinates of this axis
/// </param>
/// <param name="coordinateMin">
/// The coordinate of the first sample of this axis
/// </param>
/// <param name="coordinateMax">
/// The coordinate of the last sample of this axis
/// </param>
VolumeDataAxisDescriptor(int numSamples, const char *name, const char *unit, float coordinateMin, float 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}) {} : m_numSamples(numSamples), m_name(name), m_unit(unit), m_coordinateMin(coordinateMin), m_coordinateMax(coordinateMax) {}
VolumeDataAxisDescriptor(int numSamples, const char *name, const char *unit, const FloatRange &coordinateRange) /// <summary>
: m_numSamples(numSamples), m_name(name), m_unit(unit), m_coordinateRange(coordinateRange) {} /// Get the number of samples along this axis
/// </summary>
/// <returns>
/// The number of samples along this axis
/// </returns>
int GetNumSamples() const { return m_numSamples; } int GetNumSamples() const { return m_numSamples; }
/// <summary>
/// Get the name of this axis
/// </summary>
/// <returns>
/// The name of this axis
/// </returns>
const char *GetName() const { return m_name; } const char *GetName() const { return m_name; }
/// <summary>
/// Get the unit of the coordinates of this axis
/// </summary>
/// <returns>
/// The unit of the coordinates of this axis
/// </returns>
const char *GetUnit() const { return m_unit; } const char *GetUnit() const { return m_unit; }
float GetCoordinateMin() const { return m_coordinateRange.Min; }
float GetCoordinateMax() const { return m_coordinateRange.Max; }
const FloatRange &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 /// <summary>
/// \param sampleIndex the sample index to convert /// Get the coordinate of the first sample of this axis
/// \return the coordinate /// </summary>
float SampleIndexToCoordinate(int sampleIndex) { return m_coordinateRange.Min + sampleIndex * GetCoordinateStep(); } /// <returns>
/// The coordinate of the first sample of this axis
/// </returns>
float GetCoordinateMin() const { return m_coordinateMin; }
/// <summary>
/// Get the coordinate of the last sample of this axis
/// </summary>
/// <returns>
/// The coordinate of the last sample of this axis
/// </returns>
float GetCoordinateMax() const { return m_coordinateMax; }
/// <summary>
/// Get the coordiante step size per sample
/// </summary>
/// <returns>
/// The coordiante step size per sample
/// </returns>
float GetCoordinateStep() const { return (m_numSamples > 1) ? ((m_coordinateMax - m_coordinateMin) / (m_numSamples - 1)) : 0; }
/// <summary>
/// Convert a sample index on this axis to a coordinate
/// </summary>
/// <param name="sampleIndex">
/// The sample index get the coordinate of
/// </param>
/// <returns>
/// The coordinate of the sample index
/// </returns>
float SampleIndexToCoordinate(int sampleIndex) { return m_coordinateMin + sampleIndex * GetCoordinateStep(); }
/// <summary>
/// Convert a coordinate to a sample index (rounding to the closest index) /// Convert a coordinate to a sample index (rounding to the closest index)
/// \param coordinate the coordinate to convert /// </summary>
/// \return the sample index /// <param name="coordinate">
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); } /// The coordinate to get the sample index of
/// </param>
/// <returns>
/// The sample index of the coordinate
/// </returns>
int CoordinateToSampleIndex(float coordinate) { return (coordinate == m_coordinateMin) ? 0 : (int)floorf(((coordinate - m_coordinateMin) / (m_coordinateMax - m_coordinateMin)) * (m_numSamples - 1) + 0.5f); }
}; };
} }
#endif //VOLUMEDATAAXISDESCRIPTOR_H #endif //VOLUMEDATAAXISDESCRIPTOR_H
......
...@@ -75,13 +75,14 @@ VolumeDataLayoutImpl::VolumeDataLayoutImpl(VDS &vds, ...@@ -75,13 +75,14 @@ VolumeDataLayoutImpl::VolumeDataLayoutImpl(VDS &vds,
for(int32_t dimension = 0; dimension < ArraySize(m_dimensionNumSamples); dimension++) for(int32_t dimension = 0; dimension < ArraySize(m_dimensionNumSamples); dimension++)
{ {
if(dimension < m_dimensionality) if (dimension < m_dimensionality)
{ {
assert(axisDescriptor[dimension].GetNumSamples() >= 1); assert(axisDescriptor[dimension].GetNumSamples() >= 1);
m_dimensionNumSamples[dimension] = axisDescriptor[dimension].GetNumSamples(); m_dimensionNumSamples[dimension] = axisDescriptor[dimension].GetNumSamples();
m_dimensionName[dimension] = axisDescriptor[dimension].GetName(); m_dimensionName[dimension] = axisDescriptor[dimension].GetName();
m_dimensionUnit[dimension] = axisDescriptor[dimension].GetUnit(); m_dimensionUnit[dimension] = axisDescriptor[dimension].GetUnit();
m_dimensionRange[dimension] = { axisDescriptor[dimension].GetCoordinateMin(), axisDescriptor[dimension].GetCoordinateMax() }; m_dimensionCoordinateMin[dimension] = axisDescriptor[dimension].GetCoordinateMin();
m_dimensionCoordinateMax[dimension] = axisDescriptor[dimension].GetCoordinateMax();
} }
else else
{ {
...@@ -135,12 +136,6 @@ int32_t VolumeDataLayoutImpl::GetChannelMappedValueCount(int32_t channel) const ...@@ -135,12 +136,6 @@ int32_t VolumeDataLayoutImpl::GetChannelMappedValueCount(int32_t channel) const
return m_volumeDataChannelDescriptor[channel].GetMappedValueCount(); return m_volumeDataChannelDescriptor[channel].GetMappedValueCount();
} }
FloatRange const& VolumeDataLayoutImpl::GetDimensionRange(int32_t dimension) const
{
assert(dimension >= 0 && dimension < m_dimensionality);
return m_dimensionRange[dimension];
}
const VolumeDataChannelMapping* VolumeDataLayoutImpl::GetVolumeDataChannelMapping(int32_t channel) const const VolumeDataChannelMapping* VolumeDataLayoutImpl::GetVolumeDataChannelMapping(int32_t channel) const
{ {
assert(channel >= 0 && channel < m_volumeDataChannelDescriptor.size()); assert(channel >= 0 && channel < m_volumeDataChannelDescriptor.size());
...@@ -304,7 +299,8 @@ VolumeDataAxisDescriptor VolumeDataLayoutImpl::GetAxisDescriptor(int32_t dimensi ...@@ -304,7 +299,8 @@ VolumeDataAxisDescriptor VolumeDataLayoutImpl::GetAxisDescriptor(int32_t dimensi
return VolumeDataAxisDescriptor(GetDimensionNumSamples(dimension), return VolumeDataAxisDescriptor(GetDimensionNumSamples(dimension),
GetDimensionName(dimension), GetDimensionName(dimension),
GetDimensionUnit(dimension), GetDimensionUnit(dimension),
GetDimensionRange(dimension)); GetDimensionMin(dimension),
GetDimensionMax(dimension));
} }
int VolumeDataLayoutImpl::GetDimensionNumSamples(int32_t dimension) const int VolumeDataLayoutImpl::GetDimensionNumSamples(int32_t dimension) const
......
...@@ -61,7 +61,8 @@ private: ...@@ -61,7 +61,8 @@ private:
IndexArray m_dimensionNumSamples; IndexArray m_dimensionNumSamples;
const char *m_dimensionName[Dimensionality_Max]; const char *m_dimensionName[Dimensionality_Max];
const char *m_dimensionUnit[Dimensionality_Max]; const char *m_dimensionUnit[Dimensionality_Max];
FloatRange m_dimensionRange[Dimensionality_Max]; float m_dimensionCoordinateMin[Dimensionality_Max];
float m_dimensionCoordinateMax[Dimensionality_Max];
int32_t m_fullResolutionDimension; int32_t m_fullResolutionDimension;
public: public:
...@@ -93,8 +94,6 @@ public: ...@@ -93,8 +94,6 @@ public:
int32_t GetChannelMappedValueCount(int32_t channel) const; int32_t GetChannelMappedValueCount(int32_t channel) const;
FloatRange const &GetDimensionRange(int32_t dimension) const;
VolumeDataLayer *GetVolumeDataLayerFromID(VolumeDataLayer::VolumeDataLayerID volumeDataLayerID) const; VolumeDataLayer *GetVolumeDataLayerFromID(VolumeDataLayer::VolumeDataLayerID volumeDataLayerID) const;
VolumeDataLayer *GetVolumeDataLayerFromID(VolumeDataLayer::VolumeDataLayerID volumeDataLayerID) { return const_cast<VolumeDataLayer *>(const_cast<const VolumeDataLayoutImpl *>(this)->GetVolumeDataLayerFromID(volumeDataLayerID)); } VolumeDataLayer *GetVolumeDataLayerFromID(VolumeDataLayer::VolumeDataLayerID volumeDataLayerID) { return const_cast<VolumeDataLayer *>(const_cast<const VolumeDataLayoutImpl *>(this)->GetVolumeDataLayerFromID(volumeDataLayerID)); }
...@@ -155,8 +154,8 @@ public: ...@@ -155,8 +154,8 @@ public:
const char *GetDimensionUnit(int32_t dimension) const override; const char *GetDimensionUnit(int32_t dimension) const override;
float GetDimensionMin(int32_t dimension) const override { return GetDimensionRange(dimension).Min; } float GetDimensionMin(int32_t dimension) const override { assert(dimension >= 0 && dimension < Dimensionality_Max); return m_dimensionCoordinateMin[dimension]; }
float GetDimensionMax(int32_t dimension) const override { return GetDimensionRange(dimension).Max; } float GetDimensionMax(int32_t dimension) const override { assert(dimension >= 0 && dimension < Dimensionality_Max); return m_dimensionCoordinateMax[dimension]; }
bool IsChannelUseNoValue(int32_t channel) const override { assert(channel >= 0 && channel < GetChannelCount()); return m_volumeDataChannelDescriptor[channel].IsUseNoValue(); } bool IsChannelUseNoValue(int32_t channel) const override { assert(channel >= 0 && channel < GetChannelCount()); return m_volumeDataChannelDescriptor[channel].IsUseNoValue(); }
......
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