Beispiel #1
0
    private static int totalCellCount = 0; // this is the static int that is used for the id

    public Edge(ref CellCore cell1, ref CellCore cell2, ref Node vertex1, ref Node vertex2)
    {
        this.cell1      = cell1;
        this.cell2      = cell2;
        this.vertex1    = vertex1;
        this.vertex2    = vertex2;
        id              = totalCellCount;
        totalCellCount += 1;
    }
Beispiel #2
0
 /// <summary>
 /// adds a parent to the parent list buffer while making sure there is no duplicates
 /// </summary>
 /// <param name="core"></param>
 public void addParentToBuffer(ref CellCore core)
 {
     foreach (CellCore parent in parentBuffer)
     {
         if (core.id == parent.id)
         {
             return;
         }
     }
     parentBuffer.Add(core);
 }
 /// <summary>
 /// adds a neighbor to the buffer list
 /// </summary>
 /// <param name="neighbor"></param>
 public void addNeigborToBuffer(ref CellCore neighbor)
 {
     foreach (CellCore e in neighborBuffer)
     {
         if (e.id == neighbor.id)
         {
             return;
         }
     }
     neighborBuffer.Add(neighbor);
 }
    /// <summary>
    /// interfaces the fortune line voronoi and the rest of the programm
    /// </summary>
    /// <param name="cellPos"></param>
    /// <param name="mapSize"></param>
    /// <returns></returns>
    public static VoronoiData getVoronoi(List <Vector2> cellPos, int mapSize)
    {
        VoronoiData ret = new VoronoiData();

        ret.cores = new List <CellCore>();
        ret.nodes = new List <Node>();
        ret.edges = new List <Edge>();
        foreach (Vector2 position in cellPos)
        {
            CellCore buffer = new CellCore(position);
            ret.cores.Add(buffer);
        }
        compute_and_translate_voronoi(ref ret, mapSize);
        return(ret);
    }
    /// <summary>
    /// assigns the sister / parent / neighbor relations
    /// </summary>
    /// <param name="cell1"></param>
    /// <param name="cell2"></param>
    /// <param name="vertex1"></param>
    /// <param name="vertex2"></param>
    /// <param name="metaData"></param>
    private static void compute_relations_vertex_and_cellcores(ref CellCore cell1, ref CellCore cell2, ref Node vertex1, ref Node vertex2, ref VoronoiData metaData)
    {
        cell1.addNeigborToBuffer(ref cell2);
        cell1.addChildToBuffer(ref vertex1);
        cell1.addChildToBuffer(ref vertex2);
        cell2.addNeigborToBuffer(ref cell1);
        cell2.addChildToBuffer(ref vertex1);
        cell2.addChildToBuffer(ref vertex2);
        vertex1.addSisterToBuffer(ref vertex2);
        vertex1.addParentToBuffer(ref cell1);
        vertex1.addParentToBuffer(ref cell2);
        vertex2.addSisterToBuffer(ref vertex1);
        vertex2.addParentToBuffer(ref cell1);
        vertex2.addParentToBuffer(ref cell2);
        Edge edge = new Edge(ref cell1, ref cell2, ref vertex1, ref vertex2);

        cell1.addEdgeToBuffer(edge);
        cell2.addEdgeToBuffer(edge);
        vertex1.addEdgeToBuffer(edge);
        vertex2.addEdgeToBuffer(edge);
        metaData.edges.Add(edge);
    }
Beispiel #6
0
 public Site(bool is_site = false)
 {
     coord                  = new Point();
     this.is_site           = is_site;
     this.assigned_cellCore = null;
 }