#pragma once

#include <memory>
#include <vector>

class Node;

class Edge
{
public:
    enum class State
    {
        HEALTHY,
        DIRTY
    };

    Edge(Node* node0, Node* node1, unsigned id = 0);

    ~Edge();

    static std::unique_ptr<Edge> Create(Node* node0, Node* node1, unsigned id = 0);

    void associateFace(unsigned faceId);

    void associateWithNodes();

    void clearConnectivity();

    unsigned getConnectedFaceId(std::size_t idx) const;

    State getState() const;

    unsigned getId() const;

    unsigned getNode0Id() const;

    unsigned getNode1Id() const;

    Node* getNode0() const;

    Node* getNode1() const;

    unsigned getNumConnectedFaces() const;

    Node* getOtherNode(Node* node) const;

    bool isOverlapping(Edge* edge) const;

    bool hasSameNodes(Edge* edge) const;

    void replaceNodes(Node* node0, Node* node1);

    void setState(State state);

    void setIndex(unsigned idx);

private:
    unsigned mId{0};
    Node* mNode0{nullptr};
    Node* mNode1{nullptr};

    std::vector<unsigned> mAssociatedFaceIds;

    State mState{State::HEALTHY};
};
