Contour.h 1.32 KB
Newer Older
1 2
#ifndef OERSTED_CONTOUR_H
#define OERSTED_CONTOUR_H
Jason Pries's avatar
Jason Pries committed
3

4 5 6 7
#include <memory>
#include <vector>

#include "Curve.h"
Jason Pries's avatar
Jason Pries committed
8 9 10

class Contour {
public:
11 12 13 14 15 16 17
    Contour() : Curves(std::vector<std::shared_ptr<Curve const>>()), Orientation(std::vector<bool>()) {};

    Contour(std::vector<std::shared_ptr<Curve const>> const &c);

    Contour(std::vector<std::shared_ptr<Curve const>> const &c, std::vector<bool> const &dir);

    size_t size() const { return Curves.size(); };
Jason Pries's avatar
Jason Pries committed
18

19
    auto begin() { return Curves.begin(); };
Jason Pries's avatar
Jason Pries committed
20

21
    auto end() { return Curves.end(); };
Jason Pries's avatar
Jason Pries committed
22

23
    auto begin() const { return Curves.begin(); };
Jason Pries's avatar
Jason Pries committed
24

25
    auto end() const { return Curves.end(); };
Jason Pries's avatar
Jason Pries committed
26

27
    bool initialize(std::vector<std::shared_ptr<Curve const>> const &c, std::vector<bool> const &dir);
Jason Pries's avatar
Jason Pries committed
28

29
    bool orientation(size_t i) const { return Orientation[i]; };
Jason Pries's avatar
Jason Pries committed
30

31 32 33 34 35 36 37
    bool operator==(Contour const &rhs) const;

    double area() const;

    std::shared_ptr<Vertex const> vertex(size_t i) const { return (Orientation[i] ? Curves[i]->start() : Curves[i]->end()); };

    std::shared_ptr<Curve const> curve(size_t i) const { return Curves[i]; };
Jason Pries's avatar
Jason Pries committed
38

39 40
    std::vector<std::shared_ptr<Curve const>> curves() const { return Curves; };

Jason Pries's avatar
Jason Pries committed
41
private:
42 43 44
    std::vector<std::shared_ptr<Curve const>> Curves;

    std::vector<bool> Orientation;
Jason Pries's avatar
Jason Pries committed
45 46
};

47
#endif //OERSTED_CONTOUR_H