Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/raster/Vectorizer.java @ 437:b624879d2902
Added vectorizer rings callback to generate iso lines.
gnv-artifacts/trunk@485 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 27 Dec 2009 05:25:40 +0000 |
parents | 6642ab6c583c |
children | f42ed4f10b79 |
comparison
equal
deleted
inserted
replaced
436:6642ab6c583c | 437:b624879d2902 |
---|---|
36 public Edge(int a, int b) { | 36 public Edge(int a, int b) { |
37 this.a = a; | 37 this.a = a; |
38 this.b = b; | 38 this.b = b; |
39 } | 39 } |
40 | 40 |
41 public Edge(Edge other) { | |
42 a = other.a; | |
43 b = other.b; | |
44 } | |
45 | |
41 public void chain(Edge other, int found) { | 46 public void chain(Edge other, int found) { |
42 | 47 |
43 if (found == a) { | 48 if (found == a) { |
44 other.next = this; | 49 other.next = this; |
45 prev = other; | 50 prev = other; |
68 } | 73 } |
69 | 74 |
70 public int length() { | 75 public int length() { |
71 int length = 0; | 76 int length = 0; |
72 Edge current = this; | 77 Edge current = this; |
73 do { ++length; } while ((current = current.next) != this); | 78 do { ++length; } |
79 while ((current = current.next) != null && current != this); | |
74 return length; | 80 return length; |
75 } | 81 } |
76 | 82 |
77 public int hashCode() { | 83 public int hashCode() { |
78 return (a << 16) | b; | 84 return (a << 16) | b; |
89 Edge e1 = edge; | 95 Edge e1 = edge; |
90 Edge e2 = edge.next; | 96 Edge e2 = edge.next; |
91 Edge e3 = e2.next; | 97 Edge e3 = e2.next; |
92 | 98 |
93 int length = edge.length(); | 99 int length = edge.length(); |
100 | |
101 if (length < 2) { | |
102 return e1; | |
103 } | |
94 | 104 |
95 int count = 0; | 105 int count = 0; |
96 | 106 |
97 do { | 107 do { |
98 int e1x = e1.a % width; | 108 int e1x = e1.a % width; |
116 e2 = e2.next; | 126 e2 = e2.next; |
117 e3 = e3.next; | 127 e3 = e3.next; |
118 ++count; | 128 ++count; |
119 } | 129 } |
120 } | 130 } |
121 while (count < length + 2); | 131 while (length > 1 && count < length + 2); |
122 | 132 |
123 return e1; | 133 return e1; |
124 } | 134 } |
125 | 135 |
126 protected int [] raster; | 136 protected int [] raster; |
169 } | 179 } |
170 | 180 |
171 protected void emit(Edge edge) { | 181 protected void emit(Edge edge) { |
172 | 182 |
173 Edge otherA = (Edge)openEdges.remove(edge.a); | 183 Edge otherA = (Edge)openEdges.remove(edge.a); |
174 | |
175 if (otherA != null) { | 184 if (otherA != null) { |
176 otherA.chain(edge, edge.a); | 185 otherA.chain(edge, edge.a); |
177 } | 186 } |
178 | 187 |
179 Edge otherB = (Edge)openEdges.remove(edge.b); | 188 Edge otherB = (Edge)openEdges.remove(edge.b); |