#pragma once

#include <memory>
#include <vector>

class Node;

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

    Edge(Node* node0, Node* node1, std::size_t id = 0);

    ~Edge();

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

    void associateFace(std::size_t faceId);

    void associateWithNodes();

    void clearConnectivity();

    std::size_t getConnectedFaceId(std::size_t idx) const;

    State getState() const;

    std::size_t getId() const;

    std::size_t getNode0Id() const;

    std::size_t getNode1Id() const;

    Node* getNode0() const;

    Node* getNode1() const;

    std::size_t 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(std::size_t idx);

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

    std::vector<std::size_t> mAssociatedFaceIds;

    State mState{State::HEALTHY};
};
