Volume Cartographer 2.27.0
ParticleChain.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6#include <vector>
7
8#include <opencv2/core.hpp>
9
12
14{
23{
24public:
26 using Chain = std::vector<Particle>;
27
29 ParticleChain() = default;
30
32 explicit ParticleChain(Chain c) : data_{std::move(c)} {}
33
41 auto operator+=(const ForceChain& rhs) -> ParticleChain&;
42
44 auto operator*=(const double& rhs) -> ParticleChain&;
45
47 auto operator[](std::size_t i) { return data_[i]; }
48
50 auto operator[](std::size_t i) const { return data_[i]; }
51
53 auto begin() { return data_.begin(); }
54
56 auto begin() const { return data_.begin(); }
57
59 auto end() { return data_.end(); }
60
62 auto end() const { return data_.end(); }
63
65 template <class... Args>
66 void emplace_back(Args&&... args)
67 {
68 data_.emplace_back(std::forward<Args>(args)...);
69 }
70
72 void push_back(const Particle& val) { data_.push_back(val); }
73
75 auto size() -> std::size_t { return data_.size(); }
76
78 auto size() const -> std::size_t { return data_.size(); }
79
81 void clear() { data_.clear(); }
82
83private:
86};
87
93auto operator*(ParticleChain lhs, const double& rhs) -> ParticleChain;
95auto operator*(const double& rhs, ParticleChain lhs) -> ParticleChain;
96} // namespace volcart::segmentation
A simple class for tracking a list of offset vectors ("forces")
Definition: ForceChain.hpp:24
A simple class for keeping track of a connected chain of Particle objects.
auto begin()
Returns an iterator to the beginning of the chain.
ParticleChain(Chain c)
Constructor with chain initialization.
auto operator[](std::size_t i) const
Element access operator.
auto size() const -> std::size_t
Returns the number of elements in the chain.
auto end() const
Returns an iterator to the end of the chain.
ParticleChain()=default
Default constructor.
auto size() -> std::size_t
Returns the number of elements in the chain.
void emplace_back(Args &&... args)
Constructs an element at the end of the chain.
auto end()
Returns an iterator to the end of the chain.
auto operator+=(const ForceChain &rhs) -> ParticleChain &
Add a list of offset vectors to each element in the chain.
void clear()
Empties and resets the chain.
auto operator*=(const double &rhs) -> ParticleChain &
Multiply each element of chain by a constant scale factor.
auto operator[](std::size_t i)
Element access operator.
auto begin() const
Returns an iterator to the beginning of the chain.
void push_back(const Particle &val)
Adds an element to the end of the chain.
A simple particle class.
Definition: Particle.hpp:18
Segmentation algorithms and utilities library
auto operator+(ForceChain lhs, const ForceChain &rhs) -> ForceChain
auto operator*(ForceChain lhs, const double &rhs) -> ForceChain