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

33
LINES

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

JavaX fragment (include)

1  
srecord noeq G22SkeletonWalker<Img>(IImageRegion<Img> region) is Steppable {
2  
  // nodes by starting point (filled during exploration)
3  
  new Map<Pt, Node> nodesByPt;
4  
  
5  
  // temporary data
6  
  
7  
  ItIt<Pt> ptIterator; // region pixel iterator
8  
  new LinkedList<Pair<Node, Pt>> queue; // incomplete nodes queue (with point to check)
9  
  
10  
  // each node is a path, at the end of which there is an optional
11  
  // junction with multiple branches
12  
  class Node {
13  
    new PtBuffer path;
14  
    L<Node> branches; // junction part (optional)
15  
     
16  
    Pt startingPt() { ret first(path); }
17  
  }
18  
  
19  
    public bool step() {
20  
    ping();
21  
    
22  
    if (nempty(queue)) {
23  
      Pt p = popFirst(queue);
24  
    }
25  
    
26  
    if (ptIterator == null)
27  
      ptIterator = region.pixelIterator();
28  
      
29  
    fOr (A b : getChildren.get(a))
30  
      add(b, a);
31  
    true;
32  
  }
33  
}

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: 128 / 140
Referenced in: [show references]