simple_info.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Simple Information API, mainly designed for use in the ECMAScript console.
  3. */
  4. /**
  5. * Returns intersection points between the two given entities or shapes.
  6. * \ingroup ecma_simple
  7. *
  8. * \param e1 First entity, entity ID or shape.
  9. * \param e2 Second entity, entity ID or shape.
  10. * \param limited True to only return intersection points that lay
  11. * on the given entities or shapes (visible intersections).
  12. */
  13. function getIntersectionPoints(e1, e2, limited) {
  14. if (isNull(limited)) {
  15. limited = true;
  16. }
  17. // document is required if entity IDs are passed:
  18. var doc = undefined;
  19. if (isNumber(e1) || isNumber(e2)) {
  20. doc = getDocument();
  21. if (isNull(doc)) {
  22. return [];
  23. }
  24. }
  25. if (isNumber(e1)) {
  26. var entity1 = doc.queryEntityDirect(e1);
  27. e1 = entity1.data();
  28. }
  29. if (isNumber(e2)) {
  30. var entity2 = doc.queryEntityDirect(e2);
  31. e2 = entity2.data();
  32. }
  33. if (isEntity(e1) && isEntity(e2)) {
  34. return e1.getIntersectionPoints(e2, limited);
  35. }
  36. if (isShape(e1) && isShape(e2)) {
  37. return e1.getIntersectionPoints(e2, limited);
  38. }
  39. if (isEntity(e1) && isShape(e2)) {
  40. return e1.getIntersectionPointsWithShape(e2, limited);
  41. }
  42. if (isShape(e1) && isEntity(e2)) {
  43. return e2.getIntersectionPointsWithShape(e1, limited);
  44. }
  45. return [];
  46. }