Skip to content

Commit

Permalink
Merge pull request #268 from yngve793/Remove_unused_code_from_axis
Browse files Browse the repository at this point in the history
Clean up axis class
  • Loading branch information
yngve793 authored May 30, 2024
2 parents 3036a32 + 2233acd commit 2d8bba8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 61 deletions.
62 changes: 4 additions & 58 deletions internal/core/axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@


Axis::Axis(
OpenVDS::VolumeDataLayout const * const layout,
int const dimension
OpenVDS::VolumeDataLayout const* const layout,
int const dimension
) : m_dimension(dimension),
m_axis_descriptor(layout->GetAxisDescriptor(dimension))
{}
Expand Down Expand Up @@ -44,69 +44,15 @@ std::string Axis::name() const noexcept(true) {
}

bool Axis::inrange(float coordinate) const noexcept(true) {
return this->min() <= coordinate && this->max() >= coordinate;
return this->min() <= coordinate && this->max() >= coordinate;
}

bool Axis::inrange_with_margin(float coordinate) const noexcept(true) {
return (this->min() - 0.5 * this->stepsize()) <= coordinate &&
(this->max() + 0.5 * this->stepsize()) > coordinate;
(this->max() + 0.5 * this->stepsize()) > coordinate;
}

float Axis::to_sample_position(float coordinate) noexcept(false) {
return this->m_axis_descriptor.CoordinateToSamplePosition(coordinate);
}

void Axis::assert_equal(Axis const& other) noexcept(false) {

if (this->nsamples() != other.nsamples()) {
throw detail::bad_request(
"Axis: " + this->name() +
": Mismatch in number of samples: " +
utils::to_string_with_precision(this->nsamples()) +
" != " + utils::to_string_with_precision(other.nsamples()));
}

if (this->min() != other.min()) {
throw detail::bad_request(
"Axis: " + this->name() +
": Mismatch in min value: " +
utils::to_string_with_precision(this->min()) +
" != " + utils::to_string_with_precision(other.min()));
}

if (this->max() != other.max()) {
throw detail::bad_request(
"Axis: " + this->name() +
": Mismatch in max value: " +
utils::to_string_with_precision(this->max()) +
" != " + utils::to_string_with_precision(other.max()));
}

// Stepsize is a data integrity check.
// If min,max and nsamples are equal stepsize is equal for consistent data.
if (this->stepsize() != other.stepsize()) {
throw detail::bad_request(
"Axis: " + this->name() +
": Mismatch in stepsize: " +
std::to_string(this->stepsize()) +
" != " + std::to_string(other.stepsize()));
}

if (this->unit() != other.unit()) {
throw detail::bad_request(
"Axis: " + this->name() +
": Mismatch in unit: " +
this->unit() +
" != " + other.unit());
}

// Ignore order of dimensions

if (this->name() != other.name()) {
throw detail::bad_request(
"Axis: " + this->name() +
": Mismatch in name: " +
this->name() +
" != " + other.name());
}
}
4 changes: 1 addition & 3 deletions internal/core/axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Axis {
public:
Axis(
OpenVDS::VolumeDataLayout const * const layout,
OpenVDS::VolumeDataLayout const* const layout,
int const dimension
);

Expand Down Expand Up @@ -39,8 +39,6 @@ class Axis {
bool inrange_with_margin(float coordinate) const noexcept(true);
float to_sample_position(float coordinate) noexcept(false);

void assert_equal(Axis const& other) noexcept(false);

private:
int const m_dimension;
OpenVDS::VolumeDataAxisDescriptor m_axis_descriptor;
Expand Down

0 comments on commit 2d8bba8

Please sign in to comment.