https://github.com/GTMeijer/TIN_Viewsheds
Raw File
Tip revision: 3228d926579e0631b255e7478f24963a508637b4 authored by Gert Meijer on 06 May 2021, 03:42:18 UTC
Base code files push
Tip revision: 3228d92
ViewshedRelationGraph.h
#pragma once

namespace Viewshed
{
    class VSRelationEdge
    {
    public:

        VSRelationEdge() {};
        VSRelationEdge(int iSource, int jDestination) : iSource(iSource), jDestination(jDestination) {};

        int iSource = -1;
        int jDestination = -1;

        bool intersects = false; //i intersects j
        bool obscures = false;   //i obscures j
        bool obscured = false;   //j obscures i
    };

    class ViewshedRelationGraph
    {
    public:

        ViewshedRelationGraph() {};
        ViewshedRelationGraph(const std::vector<VSRelationEdge>& relationEdges);

        void AddEdges(const std::vector<VSRelationEdge>& relationEdges);
        void AddEdge(const VSRelationEdge& relationEdge);
        void AddNode(const int node);

        void RemoveNode(const int node);
        void RemoveNodes(const std::vector<int> nodes);
        void Trim();

        void RemoveIntersectionEdges();

        std::vector<VSRelationEdge> GetEdges(const int nodeId) const;
        int GetClosestNeighbour(const int nodeId, const std::vector<int>& priorities) const;

        std::vector<int> TopologicalSort() const;
        std::vector<int> GetStartingNodes() const;


        void ViewshedRelationGraph::PrintGraph() const;

    private:
        void TopologicalSortVisit(const int node, std::vector<int>& sortedNodes, std::map<int, bool>& visited) const;

        std::map<int, std::vector<VSRelationEdge>> nodes;
    };
}
back to top