本文整理汇总了C++中Point::PointsOnSameLine方法的典型用法代码示例。如果您正苦于以下问题:C++ Point::PointsOnSameLine方法的具体用法?C++ Point::PointsOnSameLine怎么用?C++ Point::PointsOnSameLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::PointsOnSameLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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: BreakLShape
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: BreakLShape
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: BreakLShape
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_;
}
}
}