15#ifndef O2_MCH_CONTOUR_H
16#define O2_MCH_CONTOUR_H
21#include <initializer_list>
33 std::vector<o2::mch::contour::Vertex<T>> vertices;
35 for (
const auto& p : polygons) {
37 vertices.insert(vertices.end(), pv.begin(), p.isClosed() ? pv.end() - 1 : pv.end());
46 std::vector<Vertex<T>> vertices{
getVertices(polygons)};
47 std::sort(vertices.begin(), vertices.end());
54 for (
const auto& p : polygons) {
55 if (!p.isCounterClockwiseOriented()) {
80 mPolygons.push_back(polygon);
86 for (
const auto& p : mPolygons) {
87 if (p.contains(
x,
y)) {
96 for (
const auto& p : mPolygons) {
113 std::vector<o2::mch::contour::Polygon<T>>
getPolygons()
const {
return mPolygons; }
117 os << contour.mPolygons;
122 std::vector<o2::mch::contour::Polygon<T>> mPolygons;
128 return !(rhs == lhs);
138 std::vector<Vertex<T>> vl{lhs.getSortedVertices()};
139 std::vector<Vertex<T>> vr{rhs.getSortedVertices()};
141 if (vl.size() != vr.size()) {
144 for (
auto i = 0;
i < vl.size(); ++
i) {
145 if (vl[
i] != vr[
i]) {
155 os <<
"MULTIPOLYGON(";
157 for (
auto j = 0;
j < polygons.size(); ++
j) {
160 for (
auto i = 0;
i < p.size(); ++
i) {
161 os << p[
i].x <<
" " << p[
i].y;
162 if (
i < p.size() - 1) {
167 if (
j < polygons.size() - 1) {
bool contains(T x, T y) const
typename std::vector< o2::mch::contour::Polygon< T > >::size_type size_type
Contour< T > & addPolygon(const Polygon< T > &polygon)
friend std::ostream & operator<<(std::ostream &os, const Contour< T > &contour)
bool isCounterClockwiseOriented() const
std::vector< o2::mch::contour::Polygon< T > > getPolygons() const
std::vector< o2::mch::contour::Vertex< T > > getVertices() const
o2::mch::contour::Polygon< T > operator[](int i) const
Contour(std::initializer_list< o2::mch::contour::Polygon< T > > args)
std::vector< o2::mch::contour::Vertex< T > > getSortedVertices() const
std::vector< o2::mch::contour::Vertex< T > > getVertices(const std::vector< o2::mch::contour::Polygon< T > > &polygons)
bool isCounterClockwiseOriented(const std::vector< T > &polygons)
bool operator!=(const Contour< T > &lhs, const Contour< T > &rhs)
BBox< T > getBBox(const Contour< T > &contour)
bool operator==(const Contour< T > &lhs, const Contour< T > &rhs)
std::vector< o2::mch::contour::Vertex< T > > getSortedVertices(const std::vector< o2::mch::contour::Polygon< T > > &polygons)
std::ostream & operator<<(std::ostream &os, const std::vector< o2::mch::contour::Polygon< T > > &polygons)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...