Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Cleanup: Move single lines from readonly section source to header #414

Merged
merged 7 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions include/morphio/section.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,46 +42,66 @@ class Section: public SectionBase<Section>
/**
Depth first search iterator
**/
depth_iterator depth_begin() const;
depth_iterator depth_end() const;
depth_iterator depth_begin() const {
return depth_iterator(*this);
}
depth_iterator depth_end() const {
return depth_iterator();
}

/**
Breadth first search iterator
**/
breadth_iterator breadth_begin() const;
breadth_iterator breadth_end() const;
breadth_iterator breadth_begin() const {
return breadth_iterator(*this);
}
breadth_iterator breadth_end() const {
return breadth_iterator();
}

/**
Upstream first search iterator
**/
upstream_iterator upstream_begin() const;
upstream_iterator upstream_end() const;
upstream_iterator upstream_begin() const {
return upstream_iterator(*this);
}
upstream_iterator upstream_end() const {
return upstream_iterator();
}

/**
* Return a view
(https://github.com/isocpp/CppCoreGuidelines/blob/master/docs/gsl-intro.md#gslspan-what-is-gslspan-and-what-is-it-for)
to this section's point coordinates
**/
range<const Point> points() const;
range<const Point> points() const {
return get<Property::Point>();
}

/**
* Return a view
(https://github.com/isocpp/CppCoreGuidelines/blob/master/docs/gsl-intro.md#gslspan-what-is-gslspan-and-what-is-it-for)
to this section's point diameters
**/
range<const floatType> diameters() const;
range<const floatType> diameters() const {
return get<Property::Diameter>();
}

/**
* Return a view
(https://github.com/isocpp/CppCoreGuidelines/blob/master/docs/gsl-intro.md#gslspan-what-is-gslspan-and-what-is-it-for)
to this section's point perimeters
**/
range<const floatType> perimeters() const;
range<const floatType> perimeters() const {
return get<Property::Perimeter>();
}

/**
* Return the morphological type of this section (dendrite, axon, ...)
*/
SectionType type() const;
SectionType type() const {
return properties_->get<Property::SectionType>()[id_];
}

/**
* Return true if the sections of the tree downstream (downstream = true) or upstream
Expand Down
47 changes: 2 additions & 45 deletions src/section.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#include <algorithm> // all_of
#include <algorithm> // any_of

#include <morphio/morphology.h>
#include <morphio/section.h>
#include <morphio/tools.h>
#include <morphio/vector_types.h>

#include "point_utils.h"
#include "point_utils.h" // operator<<

namespace morphio {

Expand All @@ -17,46 +14,6 @@ bool Section::isHeterogeneous(bool downstream) const {
return std::any_of(upstream_begin(), upstream_end(), predicate);
}

SectionType Section::type() const {
return properties_->get<Property::SectionType>()[id_];
}

depth_iterator Section::depth_begin() const {
return depth_iterator(*this);
}

depth_iterator Section::depth_end() const {
return depth_iterator();
}

breadth_iterator Section::breadth_begin() const {
return breadth_iterator(*this);
}

breadth_iterator Section::breadth_end() const {
return breadth_iterator();
}

upstream_iterator Section::upstream_begin() const {
return upstream_iterator(*this);
}

upstream_iterator Section::upstream_end() const {
return upstream_iterator();
}

range<const Point> Section::points() const {
return get<Property::Point>();
}

range<const floatType> Section::diameters() const {
return get<Property::Diameter>();
}

range<const floatType> Section::perimeters() const {
return get<Property::Perimeter>();
}

bool Section::hasSameShape(const Section& other) const noexcept {
return (other.type() == type() && other.diameters() == diameters() &&
other.points() == points() && other.perimeters() == perimeters());
Expand Down