SimpleNoder.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import NodedSegmentString from './NodedSegmentString'
  2. import SinglePassNoder from './SinglePassNoder'
  3. export default class SimpleNoder extends SinglePassNoder {
  4. constructor() {
  5. super()
  6. SimpleNoder.constructor_.apply(this, arguments)
  7. }
  8. static constructor_() {
  9. this._nodedSegStrings = null
  10. }
  11. computeNodes(inputSegStrings) {
  12. this._nodedSegStrings = inputSegStrings
  13. for (let i0 = inputSegStrings.iterator(); i0.hasNext(); ) {
  14. const edge0 = i0.next()
  15. for (let i1 = inputSegStrings.iterator(); i1.hasNext(); ) {
  16. const edge1 = i1.next()
  17. this.computeIntersects(edge0, edge1)
  18. }
  19. }
  20. }
  21. computeIntersects(e0, e1) {
  22. const pts0 = e0.getCoordinates()
  23. const pts1 = e1.getCoordinates()
  24. for (let i0 = 0; i0 < pts0.length - 1; i0++)
  25. for (let i1 = 0; i1 < pts1.length - 1; i1++)
  26. this._segInt.processIntersections(e0, i0, e1, i1)
  27. }
  28. getNodedSubstrings() {
  29. return NodedSegmentString.getNodedSubstrings(this._nodedSegStrings)
  30. }
  31. }