static Geom::PathVector
sp_split_intersects(Geom::Path path , double limit)
{
Geom::PathVector ret;
limit++;
Geom::Crossings cs = self_crossings(path);
Geom::delete_duplicates(cs);
if (!cs.empty()) { // There might be multiple intersections...
double cross1 = 0;
double path_size = path.size_open();
double cross2 = path_size;
for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); ++i) {
Geom::Crossing cx = (*i);
cross1 = cx.ta > cx.tb ? cx.tb : cx.ta;
cross2 = cx.ta < cx.tb ? cx.tb : cx.ta;
if(cross2 < 1e-4 ||
cross1 < 1e-4 ||
cross1 > path_size ||
cross1 > path_size ||
cross2 > path_size ||
(fabs(cross2 - cross1) < Geom::EPSILON) ||
((fabs(cross1) < Geom::EPSILON) &&
(fabs(cross2 - path_size) < Geom::EPSILON))
)
{
continue;
}
Geom::Path portion_a;
Geom::Path portion_b;
Geom::Path portion_c;
std::cout << "EXCEPTON HERE\n";
portion_a = path.portion(0, cross1);
portion_b = path.portion(cross1, cross2);
portion_b.close(); //always closed
portion_c = path.portion(cross2, path_size);
portion_c.setInitial(portion_a.finalPoint());
portion_a.append(portion_c);
if(path.closed()){
portion_a.close();
}
Geom::PathVector tmp_pathvector;
//limit the recursion
if(limit - 1 > path_size * 2){
return ret;
}
std::cout << limit << "limit\n";
if(portion_a != portion_b ){
if(portion_a != path && portion_b != path){
tmp_pathvector = sp_split_intersects(portion_a, limit);
ret.insert(ret.begin(), tmp_pathvector.begin(), tmp_pathvector.end());
tmp_pathvector = sp_split_intersects(portion_b, limit);
ret.insert(ret.begin(), tmp_pathvector.begin(), tmp_pathvector.end());
}
}
return ret;
}
}
ret.push_back(path);
return ret;
}
-
请登录后发言!