Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1034999 // G22SkeletonWalker [backup]

JavaX fragment (include)

srecord noeq G22SkeletonWalker<Img>(IImageRegion<Img> region) is Steppable {
  // nodes by starting point (filled during exploration)
  new Map<Pt, Node> nodesByPt;
  
  // temporary data
  
  ItIt<Pt> ptIterator; // region pixel iterator
  new LinkedList<Pair<Node, Pt>> queue; // incomplete nodes queue (with point to check)
  
  // each node is a path, at the end of which there is an optional
  // junction with multiple branches
  class Node {
    new PtBuffer path;
    L<Node> branches; // junction part (optional)
     
    Pt startingPt() { ret first(path); }
  }
  
    public bool step() {
    ping();
    
    if (nempty(queue)) {
      Pt p = popFirst(queue);
    }
    
    if (ptIterator == null)
      ptIterator = region.pixelIterator();
      
    fOr (A b : getChildren.get(a))
      add(b, a);
    true;
  }
}

Author comment

Began life as a copy of #1034998

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034999
Snippet name: G22SkeletonWalker [backup]
Eternal ID of this version: #1034999/1
Text MD5: 4867536b195e326fa4b8abaefd4c2276
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-22 14:41:27
Source code size: 861 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 46 / 55
Referenced in: [show references]