|
@@ -192,13 +192,13 @@ point base_path::cross(const vertex_list&v, const base_path&o)const
|
|
|
|
|
|
return l0.crossing(l1);
|
|
|
}
|
|
|
-void log_path(const std::vector<base_path>&path,const vertex_list&v_list)
|
|
|
+void log_path(const std::vector<base_path>&path,const vertex_list&v_list,const char*add_info="")
|
|
|
{
|
|
|
log_info("%s\n","----------------------------------------------------------------");
|
|
|
for(int i=0,len=path.size();i<len;i++)
|
|
|
{
|
|
|
double c=path[i].arg(v_list)/PI*180;
|
|
|
- log_info("base_path %.6lf, %03d,(%d,%s),(%d,%s)",c,i,path[i][0],v_list[path[i][0]].to_string().c_str(),path[i][1],v_list[path[i][1]].to_string().c_str());
|
|
|
+ log_info("base_path:%s %.6lf, %03d,(%d,%s),(%d,%s)",add_info,c,i,path[i][0],v_list[path[i][0]].to_string().c_str(),path[i][1],v_list[path[i][1]].to_string().c_str());
|
|
|
}
|
|
|
}
|
|
|
struct handle_path :visitor<std::shared_ptr<site>>
|
|
@@ -259,79 +259,7 @@ struct handle_path :visitor<std::shared_ptr<site>>
|
|
|
};
|
|
|
static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list&v)
|
|
|
{
|
|
|
-// for(uint32_t i=0;i<sites.m_list.size();i++)
|
|
|
-// {
|
|
|
-// auto&s=sites[i];
|
|
|
-//
|
|
|
-// if(!s.have_valid_path())
|
|
|
-// continue;
|
|
|
-//
|
|
|
-// if(s.path(0).empty()||s.path(1).empty())
|
|
|
-// continue;
|
|
|
-// if(s[0].size()<2)
|
|
|
-// continue;
|
|
|
-// line_v l000 = s[0][0][0];
|
|
|
-// line_v l010 = s[0][1][0];
|
|
|
-// if(l000.is_same(l010))
|
|
|
-// {
|
|
|
-// printf("same....%d",s.m_id);
|
|
|
-// int p0=v.add(point::min(s.path(0),s.path(1)),0,s.m_id);
|
|
|
-// int p1=v.add(point::max(s.path(0),s.path(1)),0,s.m_id);
|
|
|
-//
|
|
|
-// ret.push_back(base_path(p0,p1));
|
|
|
-// ret.back().sid=s.m_id;
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// point px = l000.line::crossing(l010);
|
|
|
-// for(int i=0;i<2;i++)
|
|
|
-// {
|
|
|
-// int p0=v.add(point::min(px,s.path(i)),0,s.m_id);
|
|
|
-// int p1=v.add(point::max(px,s.path(i)),0,s.m_id);
|
|
|
-//
|
|
|
-// ret.push_back(base_path(p0,p1));
|
|
|
-// ret.back().sid=s.m_id;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// for(int i=0;i<2;i++)
|
|
|
-// {
|
|
|
-// if(!s[0][i][1].empty())
|
|
|
-// {
|
|
|
-// int p0=v.add(point::min(s[0][i][1][0],s[0][i][1][1]),0,s.m_id);
|
|
|
-// int p1=v.add(point::max(s[0][i][1][0],s[0][i][1][1]),0,s.m_id);
|
|
|
-//
|
|
|
-// ret.push_back(base_path(p0,p1));
|
|
|
-// ret.back().sid=s.m_id;
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-/*
|
|
|
-
|
|
|
- if(x.contain(s,2.5))
|
|
|
- {
|
|
|
- int p0=v.add(point::min(s.path(0),s.path(1)),0,s.m_id);
|
|
|
- int p1=v.add(point::max(s.path(0),s.path(1)),0,s.m_id);
|
|
|
|
|
|
- ret.push_back(base_path(p0,p1));
|
|
|
- ret.back().sid=s.m_id;
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- for(int j=0;j<2;j++)
|
|
|
- {
|
|
|
- if(!s.path(j).empty() && s.dist(s.path(j))<2)
|
|
|
- continue;
|
|
|
-
|
|
|
- point p=s.path(j);
|
|
|
- int p0=v.add(point::min(s,p),0,s.m_id);
|
|
|
- int p1=v.add(point::max(s,p),0,s.m_id);
|
|
|
- ret.push_back(base_path(p0,p1));
|
|
|
- ret.back().sid=s.m_id;
|
|
|
- }
|
|
|
- }
|
|
|
-*/
|
|
|
#ifdef __DEBUG__
|
|
|
log_path(ret,v);
|
|
|
printf("++++++++++++++++++++++++++++++++++++++++++++");
|
|
@@ -358,9 +286,8 @@ static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list
|
|
|
return arg<0;
|
|
|
});
|
|
|
|
|
|
-#ifdef __DEBUG__
|
|
|
- log_path(ret,v);
|
|
|
-#endif
|
|
|
+ log_path(ret,v,"合并前");
|
|
|
+ //合并相同
|
|
|
for(int i=0,len=ret.size();i<len;i++)
|
|
|
{
|
|
|
line_v li=ret[i].as_line(v);
|
|
@@ -390,7 +317,7 @@ static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list
|
|
|
ret.erase(std::remove_if(ret.begin(),ret.end(),[&v](const base_path&p){
|
|
|
return p[0]==0||p[1]==0;
|
|
|
}),ret.end());
|
|
|
-#ifdef __DEBUG__
|
|
|
+
|
|
|
std::sort(ret.begin(),ret.end(),[&v](const base_path&p1,const base_path&p2){
|
|
|
double arg=p1.arg(v)-p2.arg(v);
|
|
|
|
|
@@ -402,8 +329,7 @@ static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list
|
|
|
return arg<0;
|
|
|
});
|
|
|
|
|
|
- log_path(ret,v);
|
|
|
-#endif
|
|
|
+ log_path(ret,v,"合并后");
|
|
|
|
|
|
//非路径交点配置
|
|
|
std::vector<point> no_cross;
|
|
@@ -492,35 +418,12 @@ static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list
|
|
|
point&p1=v[p[1]];
|
|
|
|
|
|
//return p0.dist(p1)<0.1 || p0.empty() || p1.empty();
|
|
|
- return p0.dist(p1)<0.1;
|
|
|
+ return p0.dist(p1)<1;
|
|
|
}),ret2.end());
|
|
|
|
|
|
std::sort(ret2.begin(),ret2.end());
|
|
|
ret2.erase(std::unique(ret2.begin(),ret2.end()),ret2.end());
|
|
|
|
|
|
-/*
|
|
|
- ret.clear();
|
|
|
- for(int i=0,len=ret2.size();i<len;i++)
|
|
|
- {
|
|
|
- std::vector<line_v> tmp;
|
|
|
- tmp.push_back(ret2[i].as_line(v));
|
|
|
- for(int j=0;j<len;j++)
|
|
|
- {
|
|
|
- if(i==j) continue;
|
|
|
-
|
|
|
- if(ret[j].level(v)<ret[i].level(v))
|
|
|
- continue;
|
|
|
-
|
|
|
- line l1=ret2[j].as_line(v);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- std::sort(ret2.begin(),ret2.end(),[&v](base_path&p1,base_path&p2){
|
|
|
- return p1.arg(v)<p2.arg(v);
|
|
|
- });
|
|
|
- */
|
|
|
-
|
|
|
-#ifdef __DEBUG__
|
|
|
std::sort(ret2.begin(),ret2.end(),[&v](const base_path&p1,const base_path&p2){
|
|
|
double arg=p1.arg(v)-p2.arg(v);
|
|
|
|
|
@@ -531,9 +434,7 @@ static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list
|
|
|
|
|
|
return arg<0;
|
|
|
});
|
|
|
-
|
|
|
-#endif
|
|
|
- log_path(ret2,v);
|
|
|
+ log_path(ret2,v,"拆分后");
|
|
|
|
|
|
return std::move(ret2);
|
|
|
}
|