InteriorIntersectionFinderAdder.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import SegmentIntersector from './SegmentIntersector'
  2. import ArrayList from '../../../../java/util/ArrayList'
  3. export default class InteriorIntersectionFinderAdder {
  4. constructor() {
  5. InteriorIntersectionFinderAdder.constructor_.apply(this, arguments)
  6. }
  7. static constructor_() {
  8. this._li = null
  9. this._interiorIntersections = null
  10. const li = arguments[0]
  11. this._li = li
  12. this._interiorIntersections = new ArrayList()
  13. }
  14. processIntersections(e0, segIndex0, e1, segIndex1) {
  15. if (e0 === e1 && segIndex0 === segIndex1) return null
  16. const p00 = e0.getCoordinates()[segIndex0]
  17. const p01 = e0.getCoordinates()[segIndex0 + 1]
  18. const p10 = e1.getCoordinates()[segIndex1]
  19. const p11 = e1.getCoordinates()[segIndex1 + 1]
  20. this._li.computeIntersection(p00, p01, p10, p11)
  21. if (this._li.hasIntersection())
  22. if (this._li.isInteriorIntersection()) {
  23. for (let intIndex = 0; intIndex < this._li.getIntersectionNum(); intIndex++)
  24. this._interiorIntersections.add(this._li.getIntersection(intIndex))
  25. e0.addIntersections(this._li, segIndex0, 0)
  26. e1.addIntersections(this._li, segIndex1, 1)
  27. }
  28. }
  29. isDone() {
  30. return false
  31. }
  32. getInteriorIntersections() {
  33. return this._interiorIntersections
  34. }
  35. get interfaces_() {
  36. return [SegmentIntersector]
  37. }
  38. }