示例#1
0
vector<Point> Design::FindUnblockedPoints(Point point, int block_index) const{
    vector<Point> points;
    points.push_back(point);
    Poly block = blocks_.at(block_index);
    for (unsigned int i = 0; i < block.Size(); ++i){
        Edge edge = block.GetEdge(i);
        //only take one end for each edge to avoid duplicates
        if (point.IsProjectedOn(edge) && !point.PointsOnSameLine(block.At(i))){
            points.push_back(point.Projection(edge));
        }
    }
    return points;
}
示例#2
0
void Tree::BreakLShape(vector<Node>& nodes){
    for (set<int>::const_iterator it = branches_.begin(); it != branches_.end(); it++){
        int index = *it;
        Point point = nodes[index].point_;
        int parent_node_index = nodes[index].parent_;
        Point parent_point = nodes[parent_node_index].point_;
        if (!point.PointsOnSameLine(parent_point)){//If between point and parent_point is L shape
            //Deside the shape of L
            int support_vertical_first = 0;
            int support_horizontal_first = 0;
            for (set<int>::const_iterator it2 = branches_.begin(); it2 != branches_.end(); it2++){
                int child_branch_index = *it2;
                if (nodes[child_branch_index].parent_ == index){
                    Point child_point = nodes[child_branch_index].point_;
                    if (child_point.PointsOnSameHorizontalLine(point)){
                        support_horizontal_first++;
                    }else if (child_point.PointsOnSameVerticalLine(point)){
                        support_vertical_first++;
                    }
                }
            }
            int grandparent_point_index = nodes[parent_node_index].parent_;
            Point grandparent_point = nodes[grandparent_point_index].point_;
            if (parent_point.PointsOnSameHorizontalLine(grandparent_point)){
                        support_horizontal_first++;
            }else if (parent_point.PointsOnSameVerticalLine(grandparent_point)){
                        support_vertical_first++;
            }
            //Insert new Node into nodes and insert index into indexes_
            Point corner_point;
            if (support_vertical_first >= support_horizontal_first){
                corner_point.x = point.x;
                corner_point.y = parent_point.y;
            }else{
                corner_point.y = point.y;
                corner_point.x = parent_point.x;
            }
            Node corner_node;
            corner_node.point_ = corner_point;
            corner_node.index_ = nodes.size();
            corner_node.parent_ = parent_node_index;
            nodes.push_back(corner_node);
            insert_index(corner_node.index_);
            insert_branch(corner_node.index_);
            nodes[index].parent_ = corner_node.index_;
        }
    }
}
示例#3
0
void Design::BreakLShape(vector<Node>& nodes){
    for (int index = 0; index < nodes.size(); ++index){
        Point point = nodes[index].point_;
        int parent_node_index = nodes[index].parent_;
        Point parent_point = nodes[parent_node_index].point_;
        if (!point.PointsOnSameLine(parent_point)){//If between point and parent_point is L shape
            //Deside the shape of L
            int support_vertical_first = 0;
            int support_horizontal_first = 0;
            for (int child_branch_index = 0; child_branch_index < nodes.size(); ++child_branch_index){
                if (nodes[child_branch_index].parent_ == index){
                    Point child_point = nodes[child_branch_index].point_;
                    if (child_point.PointsOnSameHorizontalLine(point)){
                        support_horizontal_first++;
                    }else if (child_point.PointsOnSameVerticalLine(point)){
                        support_vertical_first++;
                    }
                }
            }
            int grandparent_point_index = nodes[parent_node_index].parent_;
            Point grandparent_point = nodes[grandparent_point_index].point_;
            if (parent_point.PointsOnSameHorizontalLine(grandparent_point)){
                        support_horizontal_first++;
            }else if (parent_point.PointsOnSameVerticalLine(grandparent_point)){
                        support_vertical_first++;
            }
            //Insert new Node into nodes 
            Point corner_point;
            if (support_vertical_first >= support_horizontal_first){
                corner_point.x = point.x;
                corner_point.y = parent_point.y;
            }else{
                corner_point.y = point.y;
                corner_point.x = parent_point.x;
            }
            Node corner_node;
            corner_node.point_ = corner_point;
            corner_node.index_ = nodes.size();
            corner_node.parent_ = parent_node_index;
            nodes.push_back(corner_node);
            nodes[index].parent_ = corner_node.index_;
        }
    }
}
示例#4
0
void Tree::BreakLShape(vector<Node>& nodes){
    for (set<int>::const_iterator it = branches_.begin(); it != branches_.end(); it++){
        int index = *it;
        Point point = nodes[index].point_;
        int parent_node_index = nodes[index].parent_;
        Point parent_point = nodes[parent_node_index].point_;
        if (!point.PointsOnSameLine(parent_point)){//If between point and parent_point is L shape
            //Deside the shape of L
            int support_vertical_first = 0;
            int support_horizontal_first = 0;
            for (set<int>::const_iterator it2 = branches_.begin(); it2 != branches_.end(); it2++){
                int child_branch_index = *it2;
                if (nodes[child_branch_index].parent_ == index){
                    Point child_point = nodes[child_branch_index].point_;
                    if (child_point.PointsOnSameHorizontalLine(point)){
                        support_horizontal_first++;
                    }else if (child_point.PointsOnSameVerticalLine(point)){
                        support_vertical_first++;
                    }
                }
            }
            int grandparent_point_index = nodes[parent_node_index].parent_;
            Point grandparent_point = nodes[grandparent_point_index].point_;
            if (parent_point.PointsOnSameHorizontalLine(grandparent_point)){
                        support_horizontal_first++;
            }else if (parent_point.PointsOnSameVerticalLine(grandparent_point)){
                        support_vertical_first++;
            }
            //Insert new Node into nodes and insert index into indexes_
            Point corner_point;
            if (support_vertical_first >= support_horizontal_first){
                corner_point.x = point.x;
                corner_point.y = parent_point.y;
            }else{
                corner_point.y = point.y;
                corner_point.x = parent_point.x;
            }
            Node corner_node;
            corner_node.point_ = corner_point;
            corner_node.index_ = nodes.size();
            corner_node.parent_ = parent_node_index;
            nodes.push_back(corner_node);
            insert_index(corner_node.index_);
            insert_branch(corner_node.index_);
            nodes[index].parent_ = corner_node.index_;
        }
    }

    for (set<int>::const_iterator it = indexes_.begin(); it != indexes_.end();++it){
        int node_index = *it;
        if (node_index == get_root())
            continue;
        Node node = nodes.at(node_index);
        int parent_node_index = node.parent_;
        Node parent_node = nodes.at(parent_node_index);
        Edge edge(node.point_, parent_node.point_);
        DTYPE distance = edge.Length();
        double cap = distance * CUNIT;
        if (sinks_.find(node_index) != sinks_.end())//If it is sink, beside path cap, sink cap should be included 
            cap += node.ct_;
        while (node_index != root_){
            nodes.at(parent_node_index).ct_ += cap;
            node_index = parent_node_index;
            node = nodes.at(node_index);
            parent_node_index = node.parent_;
        }

    }
}