1. static Geom::PathVector
  2. sp_split_intersects(Geom::Path path , double limit)
  3. {
  4. Geom::PathVector ret;
  5. limit++;
  6. Geom::Crossings cs = self_crossings(path);
  7. Geom::delete_duplicates(cs);
  8. if (!cs.empty()) { // There might be multiple intersections...
  9. double cross1 = 0;
  10. double path_size = path.size_open();
  11. double cross2 = path_size;
  12. for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); ++i) {
  13. Geom::Crossing cx = (*i);
  14. cross1 = cx.ta > cx.tb ? cx.tb : cx.ta;
  15. cross2 = cx.ta < cx.tb ? cx.tb : cx.ta;
  16. if(cross2 < 1e-4 ||
  17. cross1 < 1e-4 ||
  18. cross1 > path_size ||
  19. cross1 > path_size ||
  20. cross2 > path_size ||
  21. (fabs(cross2 - cross1) < Geom::EPSILON) ||
  22. ((fabs(cross1) < Geom::EPSILON) &&
  23. (fabs(cross2 - path_size) < Geom::EPSILON))
  24. )
  25. {
  26. continue;
  27. }
  28. Geom::Path portion_a;
  29. Geom::Path portion_b;
  30. Geom::Path portion_c;
  31. std::cout << "EXCEPTON HERE\n";
  32. portion_a = path.portion(0, cross1);
  33. portion_b = path.portion(cross1, cross2);
  34. portion_b.close(); //always closed
  35. portion_c = path.portion(cross2, path_size);
  36. portion_c.setInitial(portion_a.finalPoint());
  37. portion_a.append(portion_c);
  38. if(path.closed()){
  39. portion_a.close();
  40. }
  41. Geom::PathVector tmp_pathvector;
  42. //limit the recursion
  43. if(limit - 1 > path_size * 2){
  44. return ret;
  45. }
  46. std::cout << limit << "limit\n";
  47. if(portion_a != portion_b ){
  48. if(portion_a != path && portion_b != path){
  49. tmp_pathvector = sp_split_intersects(portion_a, limit);
  50. ret.insert(ret.begin(), tmp_pathvector.begin(), tmp_pathvector.end());
  51. tmp_pathvector = sp_split_intersects(portion_b, limit);
  52. ret.insert(ret.begin(), tmp_pathvector.begin(), tmp_pathvector.end());
  53. }
  54. }
  55. return ret;
  56. }
  57. }
  58. ret.push_back(path);
  59. return ret;
  60. }
 
 

31

 

996

Pasted Text #1022

-

PasteBin

Linhas
60
Palavras
193
Tamanho
2,3 KB
Criado
Tipo
text/plain
Public Domain (PD)
Por favor faça seu login para deixar um comentário!