00001 package commandline.Encoder;
00002
00003 import junit.framework.Assert;
00004
00005 import commandline.CodingUtils.ByteConvertor;
00006 import commandline.ImageStuff.Image;
00007 import commandline.ImageStuff.Loc;
00008 import commandline.ImageStuff.Pixel;
00009 import commandline.ImageStuff.GeometricObjects.GenericEdge;
00010 import commandline.ImageStuff.GeometricObjects.ParametrizedPiercingVertex;
00011 import commandline.ImageStuff.GeometricObjects.TwoValuedParametrizedPiercingVertex;
00012 import commandline.ImageStuff.GeometricObjects.Vertex;
00013 import commandline.ImageStuff.util.Index_VertexCompound;
00014 import commandline.NormalMeshAlgorithm.Configuration;
00015 import commandline.NormalMeshAlgorithm.PiercingResult;
00016 import commandline.debuggingCode.Debug;
00017
00024 public class TwoValuedSnijPixelFunctieWaardeSlopeStrategy extends
00025 SnijPixelFunctieWaardeSlopeStrategy {
00026
00027 public TwoValuedSnijPixelFunctieWaardeSlopeStrategy(
00028 Configuration configuration) {
00029 super(configuration);
00030
00031 }
00032
00039 public Children_OffsetsCompoud buildChildEdges(GenericEdge edge) {
00040 EncoderEdge e = null;
00041
00042 try {
00043 e = (EncoderEdge) edge;
00044 } catch (ClassCastException ex) {
00045 Debug.print("The edge is not an EncoderEdge");
00046 System.exit(-2);
00047 }
00048
00049 EncoderEdge beginEdge, eindEdge;
00050
00051 if (e.getLengte() == 1) {
00052 return new Children_OffsetsCompoud(e, e, 0,
00053 calculateVerticalOffset(e.getBegin().getZ(), Image
00054 .getInstance().getPuntOpEnty(e.getEind()).getZ()));
00055 }
00056
00057 if (e.getLengte() == 2) {
00058 if (e.getBegin().getZ() > e.getEind().getZ()) {
00059
00060 Children_OffsetsCompoud ch = new Children_OffsetsCompoud(
00061 new TwoValuedEncoderEdge(e.getBegin(), e.getBegin(),
00062 configuration.getMaxRico()), e, 0, calculateVerticalOffset(e
00063 .getBegin().getZ(), Image.getInstance()
00064 .getPuntOpEnty(e.getBegin()).getZ()));
00065 return ch;
00066 } else {
00067 Children_OffsetsCompoud ch = new Children_OffsetsCompoud(e,
00068 new TwoValuedEncoderEdge(e.getEind(), e.getEind(),
00069 configuration.getMaxRico()), 1, calculateVerticalOffset(e
00070 .getEind().getZ(), Image.getInstance()
00071 .getPuntOpEnty(e.getEind()).getZ()));
00072 return ch;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 }
00090
00091 Index_VertexCompound i_v = SnijPixel_echte_edge(e, Image.getInstance());
00092 Assert.assertTrue(slopeconstraint(i_v));
00093 int[][] lijn = maakLijn(0, i_v.index(), e);
00094 beginEdge = makeEdge(e.getBegin(), i_v.getVertex(), lijn);
00095 lijn = maakLijn(i_v.index(), e.getLengte() - 1, e);
00096 eindEdge = makeEdge(i_v.getVertex(), e.getEind(), lijn);
00097
00098
00099
00100 Children_OffsetsCompoud ch = new Children_OffsetsCompoud(beginEdge,
00101 eindEdge, i_v.index(), calculateVerticalOffset(i_v.getVertex()
00102 .getZ(), Image.getInstance().getPuntOpEnty(
00103 i_v.getVertex()).getZ()));
00104 return ch;
00105 }
00106
00107 protected Index_VertexCompound SnijPixel_echte_edge(EncoderEdge e,
00108 Image image) {
00109 Assert.assertTrue(e.getLengte() > 2);
00110 int midden_index = e.getMiddenIndex();
00111
00112
00113
00114 float rico_normale = berekenRicoNormale(e);
00115
00116 float midden_hoogte = berekenMiddenHoogte(e);
00117
00118
00119
00120 Assert
00121 .assertTrue(Math.abs(midden_hoogte) <= ByteConvertor.MAX_COLOR_VALUE);
00122
00123 if (e.isFlat()) {
00124
00125
00126 float waarde = Image.getInstance().getPuntOpEnty(e.getMidLoc())
00127 .getZ();
00128 Index_VertexCompound i_v = new Index_VertexCompound(midden_index,
00129 new TwoValuedParametrizedPiercingVertex(e.getMidLoc(),
00130 waarde, 0, e.getNormalisationFactor(), e));
00131
00132
00133
00134
00135 slopeconstraint(i_v);
00136 return i_v;
00137 }
00138 if (Debug.DEBUG && Debug.DEBUG_ENCODERSTUFF) {
00139 Debug.print("rico normal :=" + rico_normale);
00140 }
00141
00142 int max_delta_a = midden_index - 1;
00143 max_delta_a = max_delta_a(e, rico_normale, midden_index, midden_hoogte,
00144 max_delta_a);
00145 int max_delta_b = e.getLengte() - midden_index - 1 - 1;
00146
00147
00148
00149
00150 max_delta_b = max_delta_b(e, rico_normale, midden_index, midden_hoogte,
00151 max_delta_b);
00152
00153
00154
00155 float functiewaarde = Image.getInstance().getPuntOpEnty(
00156 e.getLoc(midden_index)).getZ();
00157
00158 boolean is_normale_boven_functie = false;
00159 if (midden_hoogte >= functiewaarde) {
00160 is_normale_boven_functie = true;
00161 }
00162
00163 float normale_waarde;
00164 float afstand;
00165 int temp_index;
00166
00167
00168
00169 PiercingResult resultnaar_a = new PiercingResult();
00170
00171
00172 boolean temp_is_normale_boven_functie = is_normale_boven_functie;
00173 for (int delta = 1; delta <= max_delta_a; delta++) {
00174
00175 afstand = e.getLoc(midden_index).distance(
00176 e.getLoc(midden_index - delta));
00177 normale_waarde = midden_hoogte - afstand * rico_normale;
00178 functiewaarde = Image.getInstance().getPuntOpEnty(
00179 e.getLoc(midden_index - delta)).getZ();
00180
00181
00182
00183
00184
00185 temp_is_normale_boven_functie = (normale_waarde >= functiewaarde);
00186
00187 if (is_normale_boven_functie != temp_is_normale_boven_functie) {
00188 PiercingResult resultnaar_a_Afterpiercing = new PiercingResult();
00189 ParametrizedPiercingVertex voorpiercing_a = new TwoValuedParametrizedPiercingVertex(
00190 e.getLoc(midden_index - delta),
00191 normale_waarde,
00192 calculateVerticalOffset(normale_waarde, Image
00193 .getInstance().getPuntOpEnty(
00194 e.getLoc(midden_index - delta)).getZ()),
00195 e.getNormalisationFactor(), e);
00196 Index_VertexCompound voorpiercing_naar_a = new Index_VertexCompound(
00197 midden_index - delta, voorpiercing_a);
00198 resultnaar_a_Afterpiercing.setIndex_VertexCompound(
00199 voorpiercing_naar_a, delta);
00200
00201 temp_index = midden_index - delta + 1;
00202 afstand = e.getLoc(midden_index).distance(e.getLoc(temp_index));
00203 normale_waarde = midden_hoogte - afstand * rico_normale;
00204
00205 functiewaarde = Image.getInstance().getPuntOpEnty(
00206 e.getLoc(temp_index)).getZ();
00207
00208
00209
00210 if (temp_index == 0) {
00211 Debug
00212 .print("temp_index valt samen met de beginlocatie dus vertex met zelfde loc wordt aangemaakt");
00213 System.exit(-1);
00214 }
00215
00216 Loc l = e.getLoc(temp_index);
00217 int verticalOffset = this.calculateVerticalOffset(
00218 normale_waarde, Image.getInstance().getPuntOpEnty(l)
00219 .getZ());
00220 ParametrizedPiercingVertex piercing = new TwoValuedParametrizedPiercingVertex(
00221 l, normale_waarde, verticalOffset, e
00222 .getNormalisationFactor(), e);
00223 Index_VertexCompound piercing_naar_a = new Index_VertexCompound(
00224 temp_index, piercing);
00225 resultnaar_a.setIndex_VertexCompound(piercing_naar_a, Math
00226 .abs(temp_index - midden_index));
00227
00228
00229 resultnaar_a = this.choosePiercingPoint(resultnaar_a,
00230 resultnaar_a_Afterpiercing, e);
00231
00232
00233 break;
00234 }
00235
00236 }
00237
00238
00239 PiercingResult resultnaar_b = new PiercingResult();
00240
00241
00242 temp_is_normale_boven_functie = is_normale_boven_functie;
00243 for (int delta = 1; delta <= max_delta_b; delta++) {
00244 afstand = e.getLoc(midden_index).distance(
00245 e.getLoc(midden_index + delta));
00246 normale_waarde = midden_hoogte + afstand * rico_normale;
00247 functiewaarde = Image.getInstance().getPuntOpEnty(
00248 e.getLoc(midden_index + delta)).getZ();
00249
00250 temp_is_normale_boven_functie = (normale_waarde >= functiewaarde);
00251
00252 if (is_normale_boven_functie != temp_is_normale_boven_functie) {
00253 PiercingResult resultnaar_b_After = new PiercingResult();
00254 ParametrizedPiercingVertex voorpiercing_b = new TwoValuedParametrizedPiercingVertex(
00255 e.getLoc(midden_index + delta),
00256 normale_waarde,
00257 calculateVerticalOffset(normale_waarde, Image
00258 .getInstance().getPuntOpEnty(
00259 e.getLoc(midden_index + delta)).getZ()),
00260 e.getNormalisationFactor(), e);
00261 Index_VertexCompound voorpiercing_naar_b = new Index_VertexCompound(
00262 midden_index + delta, voorpiercing_b);
00263 resultnaar_b_After.setIndex_VertexCompound(voorpiercing_naar_b,
00264 delta);
00265
00266 temp_index = midden_index + delta - 1;
00267
00268 afstand = e.getLoc(midden_index).distance(
00269 e.getLoc(temp_index));
00270 normale_waarde = midden_hoogte + afstand * rico_normale;
00271
00272 functiewaarde = Image.getInstance().getPuntOpEnty(
00273 e.getLoc(temp_index)).getZ();
00274
00275 Loc l = e.getLoc(temp_index);
00276 int verticalOffset = calculateVerticalOffset(normale_waarde,
00277 Image.getInstance().getPuntOpEnty(l).getZ());
00278
00279 ParametrizedPiercingVertex piercing = new TwoValuedParametrizedPiercingVertex(
00280 l, normale_waarde, verticalOffset, e
00281 .getNormalisationFactor(), e);
00282 Index_VertexCompound piercing_naar_b = new Index_VertexCompound(
00283 temp_index, piercing);
00284 resultnaar_b.setIndex_VertexCompound(piercing_naar_b, Math
00285 .abs(temp_index - midden_index));
00286
00287
00288 resultnaar_b = this.choosePiercingPoint(resultnaar_b,
00289 resultnaar_b_After, e);
00290
00291 Assert.assertTrue(obayPiercingConstraint(resultnaar_b
00292 .getIndexVertexCompound().getVertex()));
00293 break;
00294 }
00295
00296 }
00297
00298
00299
00300 if (resultnaar_a.isFound() && resultnaar_b.isFound()) {
00301 Index_VertexCompound index_VertexCompound = getPiercingClosest(
00302 resultnaar_a, max_delta_a, resultnaar_b, max_delta_b);
00303 slopeconstraint(index_VertexCompound);
00304 return index_VertexCompound;
00305 } else {
00306 if (resultnaar_a.isFound()) {
00307 slopeconstraint(resultnaar_a.getIndexVertexCompound());
00308 return resultnaar_a.getIndexVertexCompound();
00309 } else {
00310 if (resultnaar_b.isFound()) {
00311 slopeconstraint(resultnaar_b.getIndexVertexCompound());
00312 return resultnaar_b.getIndexVertexCompound();
00313 } else {
00314
00315 PiercingResult naar_a = getFarestPiercingTo_a(e,
00316 rico_normale, midden_index, midden_hoogte,
00317 max_delta_a);
00318 PiercingResult naar_b = getFarestPiercingTo_b(e,
00319 rico_normale, midden_index, midden_hoogte,
00320 max_delta_b);
00321 PiercingResult choice = getPiercingSmallestAbsVerticalOffset(
00322 naar_a, naar_b);
00323 Assert.assertTrue(obayPiercingConstraint(choice
00324 .getIndexVertexCompound().getVertex()));
00325
00326
00327 float waarde = Image.getInstance().getPuntOpEnty(
00328 e.getMidLoc()).getZ();
00329 Index_VertexCompound i_v = new Index_VertexCompound(
00330 midden_index,
00331 new TwoValuedParametrizedPiercingVertex(e
00332 .getMidLoc(), waarde, 0, e
00333 .getNormalisationFactor(), e));
00334 System.out
00335 .println("vervangen door middelpunt -> implementeer beter");
00336
00337 float afstand_naar_a_begin = Math.abs(e.getBegin().getZ()
00338 - naar_a.getIndexVertexCompound().getVertex()
00339 .getZ());
00340 float afstand_naar_b_eind = Math.abs(e.getEind().getZ()
00341 - naar_b.getIndexVertexCompound().getVertex()
00342 .getZ());
00343 boolean boven = (waarde > midden_hoogte);
00344 if (boven) {
00345 if (afstand_naar_a_begin > afstand_naar_b_eind) {
00346
00347
00348
00349 slopeconstraint(naar_a.getIndexVertexCompound());
00350 return naar_a.getIndexVertexCompound();
00351 } else {
00352 slopeconstraint(naar_b.getIndexVertexCompound());
00353 return naar_b.getIndexVertexCompound();
00354 }
00355 } else {
00356 if (afstand_naar_a_begin > afstand_naar_b_eind) {
00357
00358
00359
00360 slopeconstraint(naar_b.getIndexVertexCompound());
00361 return naar_b.getIndexVertexCompound();
00362 } else {
00363 slopeconstraint(naar_a.getIndexVertexCompound());
00364 return naar_a.getIndexVertexCompound();
00365 }
00366 }
00367 }
00368 }
00369
00370
00371
00372
00373 }
00374
00375 }
00376
00385 protected int max_delta_b(GenericEdge e, float rico_normale,
00386 int midden_index, float midden_hoogte, int max_delta) {
00387
00388 float afstand_0 = -midden_hoogte / rico_normale;
00389
00390 float afstand_255 = (ByteConvertor.MAX_COLOR_VALUE - midden_hoogte)
00391 / rico_normale;
00392
00393 float max_afstand = Math.max(afstand_0, afstand_255);
00394
00395
00396 Assert.assertTrue(max_afstand >= 0);
00397 int delta = max_delta;
00398 for (int d = 0; d != max_delta; d++) {
00399 float afstand = e.getMidLoc().distance(e.getLoc(midden_index + d));
00400 if (afstand > max_afstand) {
00401 delta = d - 1;
00402 break;
00403 }
00404 }
00405 return delta;
00406 }
00407
00416 protected int max_delta_a(GenericEdge e, float rico_normale,
00417 int midden_index, float midden_hoogte, int max_delta) {
00418
00419 float afstand_0 = -midden_hoogte / rico_normale;
00420
00421
00422
00423
00424 float afstand_255 = (ByteConvertor.MAX_COLOR_VALUE - midden_hoogte)
00425 / rico_normale;
00426
00427 float min_afstand = Math.min(afstand_0, afstand_255);
00428
00429
00430 Assert.assertTrue(min_afstand <= 0);
00431 min_afstand = Math.abs(min_afstand);
00432
00433 int delta = max_delta;
00434 for (int d = 0; d != max_delta; d++) {
00435 float afstand = e.getMidLoc().distance(e.getLoc(midden_index - d));
00436 if (afstand > min_afstand) {
00437 delta = d - 1;
00438 break;
00439 }
00440 }
00441 return delta;
00442 }
00443
00453 protected PiercingResult getFarestPiercingTo_b(GenericEdge e,
00454 float rico_normale, int midden_index, float midden_hoogte,
00455 int max_delta) {
00456 int delta = max_delta_b(e, rico_normale, midden_index, midden_hoogte,
00457 max_delta);
00458
00459 float afstand = e.getLoc(midden_index).distance(
00460 e.getLoc(midden_index + delta));
00461 float normale_waarde = midden_hoogte + afstand * rico_normale;
00462 int temp_index = midden_index + delta;
00463 Loc l = e.getLoc(temp_index);
00464 int verticalOffset = calculateVerticalOffset(normale_waarde, Image
00465 .getInstance().getPuntOpEnty(l).getZ());
00466 ParametrizedPiercingVertex piercing = new TwoValuedParametrizedPiercingVertex(
00467 l, normale_waarde, verticalOffset, e.getNormalisationFactor(),
00468 e);
00469 Index_VertexCompound piercing_naar_b = new Index_VertexCompound(
00470 temp_index, piercing);
00471 PiercingResult piercingResult = new PiercingResult();
00472 piercingResult.setIndex_VertexCompound(piercing_naar_b, delta);
00473 return piercingResult;
00474
00475 }
00476
00486 protected PiercingResult getFarestPiercingTo_a(GenericEdge e,
00487 float rico_normale, int midden_index, float midden_hoogte,
00488 int max_delta) {
00489 int delta = max_delta_a(e, rico_normale, midden_index, midden_hoogte,
00490 max_delta);
00491
00492 float afstand = e.getLoc(midden_index).distance(
00493 e.getLoc(midden_index - delta));
00494 float normale_waarde = midden_hoogte - afstand * rico_normale;
00495 int temp_index = midden_index - delta;
00496 Loc l = e.getLoc(temp_index);
00497 int verticalOffset = calculateVerticalOffset(normale_waarde, Image
00498 .getInstance().getPuntOpEnty(l).getZ());
00499 ParametrizedPiercingVertex piercing = new TwoValuedParametrizedPiercingVertex(
00500 l, normale_waarde, verticalOffset, e.getNormalisationFactor(),
00501 e);
00502 Index_VertexCompound piercing_naar_a = new Index_VertexCompound(
00503 temp_index, piercing);
00504 PiercingResult piercingResult = new PiercingResult();
00505 piercingResult.setIndex_VertexCompound(piercing_naar_a, delta);
00506 return piercingResult;
00507 }
00508
00509 protected boolean obayPiercingConstraint(Vertex piercing) {
00510 return (Math.round(piercing.getZ()) >= 0 && Math.round(piercing.getZ()) <= ByteConvertor.MAX_COLOR_VALUE);
00511 }
00512
00520 protected Index_VertexCompound getPiercingClosest(
00521 PiercingResult resultnaar_a, int max_delta_a,
00522 PiercingResult resultnaar_b, int max_delta_b) {
00523
00524
00525 if (resultnaar_a.getAantalPixelsVanafMidden() == max_delta_a - 1
00526 && resultnaar_b.getAantalPixelsVanafMidden() == max_delta_b - 1) {
00527 return getPiercingSmallestAbsVerticalOffset(resultnaar_a,
00528 resultnaar_b).getIndexVertexCompound();
00529 }
00530 if (resultnaar_a.getAantalPixelsVanafMidden() < resultnaar_b
00531 .getAantalPixelsVanafMidden()) {
00532 return resultnaar_a.getIndexVertexCompound();
00533 } else {
00534 return resultnaar_b.getIndexVertexCompound();
00535 }
00536
00537 }
00538
00546 protected PiercingResult getPiercingSmallestAbsVerticalOffset(
00547 PiercingResult resultnaar_a, PiercingResult resultnaar_b) {
00548 boolean ensure = obayPiercingConstraint(resultnaar_a
00549 .getIndexVertexCompound().getVertex())
00550 || obayPiercingConstraint(resultnaar_b.getIndexVertexCompound()
00551 .getVertex());
00552 Assert.assertTrue(ensure);
00553
00554 if (!obayPiercingConstraint(resultnaar_a.getIndexVertexCompound()
00555 .getVertex())) {
00556 return resultnaar_b;
00557 }
00558
00559 if (!obayPiercingConstraint(resultnaar_b.getIndexVertexCompound()
00560 .getVertex())) {
00561 return resultnaar_a;
00562 }
00563
00564 if (Math.abs(resultnaar_a.getIndexVertexCompound().getVertex()
00565 .getVerticalOffset()) < Math.abs(resultnaar_b
00566 .getIndexVertexCompound().getVertex().getVerticalOffset())) {
00567 return resultnaar_a;
00568 } else {
00569 return resultnaar_b;
00570 }
00571 }
00572
00576 protected EncoderEdge makeEdge(ParametrizedPiercingVertex begin,
00577 ParametrizedPiercingVertex eind, int[][] lijn) {
00578 Image image = Image.getInstance();
00579 if (begin.isOn(eind)) {
00580
00581
00582 int[][] lijn_2 = new int[1][2];
00583 lijn_2[0][0] = begin.getX();
00584 lijn_2[0][1] = begin.getY();
00585 EncoderEdge degenereerd = new TwoValuedEncoderEdge(begin, eind,
00586 image, lijn_2, configuration.getMaxRico());
00587 return degenereerd;
00588 }
00589
00590 EncoderEdge edge = new TwoValuedEncoderEdge(begin, eind, image, lijn,
00591 configuration.getMaxRico());
00592 return edge;
00593 }
00594
00605
00606 protected PiercingResult getSlopePiercingResult(
00607 PiercingResult resultBefore_Piercing,
00608 PiercingResult resultAfter_Piercing, EncoderEdge edge) {
00609 if (Math.abs(resultBefore_Piercing.getAantalPixelsVanafMidden()) > Math
00610 .abs(resultAfter_Piercing.getAantalPixelsVanafMidden())) {
00611 System.err.println("error");
00612 }
00613 float value_before = Image.getInstance().getPuntOpEnty(
00614 resultBefore_Piercing.getIndexVertexCompound().getVertex())
00615 .getZ();
00616 float value_after = Image.getInstance().getPuntOpEnty(
00617 resultAfter_Piercing.getIndexVertexCompound().getVertex())
00618 .getZ();
00619
00620 TwoValuedParametrizedPiercingVertex vertex_after_before = new TwoValuedParametrizedPiercingVertex(
00621 resultAfter_Piercing.getIndexVertexCompound().getVertex(),
00622 resultBefore_Piercing.getIndexVertexCompound().getVertex(), 0,
00623 edge);
00624 Index_VertexCompound index_VertexCompound = new Index_VertexCompound(
00625 resultAfter_Piercing.getIndexVertexCompound().index(),
00626 vertex_after_before);
00627 PiercingResult piercingResult_after_before = new PiercingResult();
00628 piercingResult_after_before.setIndex_VertexCompound(
00629 index_VertexCompound, resultAfter_Piercing
00630 .getAantalPixelsVanafMidden());
00631
00632 TwoValuedParametrizedPiercingVertex vertex_before_after = new TwoValuedParametrizedPiercingVertex(
00633 resultBefore_Piercing.getIndexVertexCompound().getVertex(),
00634 resultAfter_Piercing.getIndexVertexCompound().getVertex(), 0,
00635 edge);
00636 Index_VertexCompound index_VertexCompound_before_after = new Index_VertexCompound(
00637 resultBefore_Piercing.getIndexVertexCompound().index(),
00638 vertex_before_after);
00639 PiercingResult piercingResult_before_after = new PiercingResult();
00640 piercingResult_before_after.setIndex_VertexCompound(
00641 index_VertexCompound_before_after, resultBefore_Piercing
00642 .getAantalPixelsVanafMidden());
00643
00644 PiercingResult result;
00645
00646 if (value_before < value_after) {
00647 result = piercingResult_after_before;
00648
00649 } else {
00650 result = piercingResult_before_after;
00651 }
00652 Assert.assertTrue(slopeconstraint(result));
00653
00654 return result;
00655 }
00656
00662 private boolean slopeconstraint(PiercingResult result) {
00663 Vertex onloc = result.getIndexVertexCompound().getVertex();
00664 Vertex next_to_loc = ((TwoValuedParametrizedPiercingVertex) (result
00665 .getIndexVertexCompound().getVertex())).getNextToLoc();
00666 slopeconstraint(onloc, next_to_loc);
00667 return slopeconstraint(onloc, next_to_loc);
00668 }
00669
00670 private boolean slopeconstraint(Index_VertexCompound index_VertexCompound) {
00671 Vertex onloc = index_VertexCompound.getVertex();
00672 Vertex next_to_loc = ((TwoValuedParametrizedPiercingVertex) (index_VertexCompound
00673 .getVertex())).getNextToLoc();
00674 return slopeconstraint(onloc, next_to_loc);
00675
00676 }
00677
00678 private boolean slopeconstraint(Vertex onloc, Vertex nextloc) {
00679 float onloc_value = Image.getInstance().getPuntOpEnty(onloc).getZ();
00680 float next_to_loc_value = Image.getInstance().getPuntOpEnty(nextloc)
00681 .getZ();
00682 if (!(next_to_loc_value <= onloc_value)) {
00683
00684
00685 System.err.println("error value");
00686 return false;
00687 } else {
00688 return true;
00689 }
00690 }
00691
00699 protected float getBeginPixelWaarde(EncoderEdge e) {
00700 TwoValuedParametrizedPiercingVertex vertex = (TwoValuedParametrizedPiercingVertex) e
00701 .getBegin();
00702 return vertex.getSuitablePiercingVertexForNormalAndInterpolating(e)
00703 .getZ();
00704 }
00705
00706 protected float getEindPixelWaarde(EncoderEdge e) {
00707 TwoValuedParametrizedPiercingVertex vertex = (TwoValuedParametrizedPiercingVertex) e
00708 .getEind();
00709 return vertex.getSuitablePiercingVertexForNormalAndInterpolating(e)
00710 .getZ();
00711 }
00712
00713 protected float getPixelWaarde(Pixel p) {
00714 return Image.getInstance().getPuntOpEnty(p).getZ();
00715 }
00716
00721 public float berekenRicoNormale(GenericEdge e) {
00722 System.out.println("nieuwe rico normale");
00723 TwoValuedParametrizedPiercingVertex beginvertex = (TwoValuedParametrizedPiercingVertex) e
00724 .getEind();
00725 TwoValuedParametrizedPiercingVertex eindvertex = (TwoValuedParametrizedPiercingVertex) e
00726 .getBegin();
00727 ParametrizedPiercingVertex begin = beginvertex
00728 .getSuitablePiercingVertexForNormalAndInterpolating(e);
00729 ParametrizedPiercingVertex eind = eindvertex
00730 .getSuitablePiercingVertexForNormalAndInterpolating(e);
00731 float euclidischelengte = e.getEuclidischeLengte();
00732 float hoogte = (eind.getZ() + eind.getVerticalOffset())
00733 - (begin.getZ() + begin.getVerticalOffset());
00734 float rico_normale = -euclidischelengte / hoogte;
00735 return rico_normale;
00736 }
00737
00738 public float berekenRicoEdge(GenericEdge e) {
00739 System.out.println("nieuwe rico edge");
00740 TwoValuedParametrizedPiercingVertex beginvertex = (TwoValuedParametrizedPiercingVertex) e
00741 .getEind();
00742 TwoValuedParametrizedPiercingVertex eindvertex = (TwoValuedParametrizedPiercingVertex) e
00743 .getBegin();
00744 ParametrizedPiercingVertex begin = beginvertex
00745 .getSuitablePiercingVertexForNormalAndInterpolating(e);
00746 ParametrizedPiercingVertex eind = eindvertex
00747 .getSuitablePiercingVertexForNormalAndInterpolating(e);
00748 float euclidischelengte = e.getEuclidischeLengte();
00749 float hoogte = (eind.getZ() + eind.getVerticalOffset())
00750 - (begin.getZ() + begin.getVerticalOffset());
00751 float rico_edge = hoogte / euclidischelengte;
00752 return rico_edge;
00753 }
00754
00755 }