Commit ada2ac85 authored by Andrey Filippov's avatar Andrey Filippov

testing/debugging diagonal swapping

parent 5d6289e3
......@@ -23,6 +23,7 @@
*/
public class Conflict{
int nsTile= -1;
int start_layer;
int end_layer;
boolean [] start_dirs = new boolean[24];
......@@ -35,9 +36,19 @@ public class Conflict{
// 16 ... 23 - ortho-ortho-diagonal (turn left)
// 16 ... 19 : 16 - start_layer->N->W->SE->end_layer, 17 - start_layer->E->N->SW->end_layer, ...
// 20 ... 23 : 20 - end_layer->N->W->SE->start_layer, 21 - end_layer->E->N->SW->start_layer, ...
Conflict(int start_layer, int end_layer, int start_dir) // for ortho-diag-ortho
private void dbgCheck(){
// if (nsTile== 630){
// System.out.println("Conflict().dbgCheck, nsTile = "+nsTile);
// System.out.println("Conflict().dbgCheck, nsTile = "+nsTile);
// }
}
public Conflict(
int nsTile,
int start_layer,
int end_layer,
int start_dir) // for ortho-diag-ortho
{
this.nsTile = nsTile;
if (end_layer > start_layer) {
this.start_layer = start_layer;
this.end_layer = end_layer;
......@@ -48,23 +59,33 @@ public class Conflict{
this.start_dirs[start_dir + 4] = true;
}
dbgCheck();
}
Conflict(int start_layer, int end_layer, int start_dir, boolean right) // for ortho-ortho-diag
Conflict(
int nsTile,
int start_layer,
int end_layer,
int start_dir,
boolean right) // for ortho-ortho-diag
{
this.nsTile = nsTile;
if (end_layer > start_layer) {
this.start_layer = start_layer;
this.end_layer = end_layer;
this.start_dirs[(right? 8 : 12) + start_dir] = true;
this.start_dirs[(right? 8 : 16) + start_dir] = true;
} else {
this.start_layer = end_layer;
this.end_layer = start_layer;
this.start_dirs[(right? 16 : 20) + start_dir] = true;
this.start_dirs[(right? 12 : 20) + start_dir] = true;
}
dbgCheck();
}
Conflict(int [] arr)
Conflict(int nsTile,
int [] arr)
{
this.nsTile = nsTile;
this.start_layer = arr[0];
this.end_layer = arr[1];
for (int i = 0; i < start_dirs.length; i++){
......@@ -78,12 +99,39 @@ public class Conflict{
for (int i = 0; i < start_dirs.length; i++){
start_dirs[i] = (bits & (1 << i)) != 0;
}
dbgCheck();
}
int getSTile()
{
return this.nsTile;
}
public String toString()
{
String s="Conflict"+
" nsTile = "+getSTile()+
" nl1 = "+ getStartLayer()+
" nl2 = "+ getEndLayer()+
" all = "+ getNumConflicts() + " ("+String.format("%06x", getDirBits())+")" +
" odo = "+ getNumOrthoDiagOrthoConflicts() +
" ood = "+ getNumOrthoOrthoDiagConflicts() +
" number of odo incompatible triangles = "+ getIncompatibleOrthoDiagOrthoConflicts() +
" number of odo dual triangles = " + getDualTriOrthoDiagOrthoConflicts();
return s;
}
public boolean conflictExists(
int start_dir4,
boolean right,
boolean reverse)
{
return start_dirs[8 + start_dir4 + (reverse? 4:0) + (right? 0 : 8)];
}
boolean combine (Conflict other_conflict)
{
dbgCheck();
if ((other_conflict.start_layer == this.start_layer) && (other_conflict.end_layer == this.end_layer)) {
for (int i = 0; i < start_dirs.length; i++) start_dirs[i] |= other_conflict.start_dirs[i];
return true;
......@@ -99,6 +147,16 @@ public class Conflict{
return end_layer;
}
int getStartLayer(boolean reverse){
return reverse? end_layer: start_layer;
}
int getEndLayer(boolean reverse){
return reverse? start_layer : end_layer;
}
int getDirBits(){
int dirs_bits = 0;
for (int i = 0; i < start_dirs.length; i++){
......@@ -191,4 +249,4 @@ public class Conflict{
}
}
}
......@@ -96,7 +96,7 @@ public class Conflicts {
{
for (int nsTile = 0; nsTile < conflicts.length; nsTile++) if (conflicts[nsTile] != null){
for (int nc = 0; nc < conflicts[nsTile].length; nc++){
Conflict conf = new Conflict(conflicts[nsTile][nc]);
Conflict conf = new Conflict(nsTile, conflicts[nsTile][nc]);
if (conf.getNumOrthoDiagOrthoConflicts() > 0) num_ortho_diag_ortho[conf.getNumOrthoDiagOrthoConflicts() - 1]++;
if (conf.getNumOrthoOrthoDiagConflicts() > 0) num_ortho_ortho_diag[conf.getNumOrthoOrthoDiagConflicts() - 1]++;
if (conf.getNumConflicts() > 0) num_all_conflicts[conf.getNumConflicts() - 1]++;
......@@ -153,14 +153,7 @@ public class Conflicts {
public void printConflict(String prefix, Conflict conf)
{
System.out.println(prefix+
" nl1 = "+ conf.getStartLayer()+
" nl2 = "+ conf.getEndLayer()+
" all = "+ conf.getNumConflicts() + " ("+String.format("%06x", conf.getDirBits())+")" +
" odo = "+ conf.getNumOrthoDiagOrthoConflicts() +
" ood = "+ conf.getNumOrthoOrthoDiagConflicts() +
" number of odo incompatible triangles = "+ conf.getIncompatibleOrthoDiagOrthoConflicts() +
" number of odo dual triangles = "+conf.getDualTriOrthoDiagOrthoConflicts());
System.out.println(prefix+conf.toString());
}
public int numBetterWorse(
......@@ -309,7 +302,7 @@ public class Conflicts {
int dir2 = (dir1 + 3) % 8;
int np3 = neibs2[dir2]; // planes[nsTile2][np2].getNeibBest(dir2);
if ((np3 >= 0) && (np3 != np0)){
Conflict conflict = new Conflict(np0, np3, dir/2);
Conflict conflict = new Conflict(nsTile0, np0, np3, dir/2);
label_apply:
{
for (Conflict conf_old:conflicts_list){
......@@ -335,7 +328,7 @@ public class Conflicts {
int dir2 = (dir1 + 3) % 8;
int np3 = neibs2[dir2]; // planes[nsTile2][np2].getNeibBest(dir2);
if ((np3 >= 0) && (np3 != np0)){
Conflict conflict = new Conflict(np0, np3, dir/2, true); // ood, right
Conflict conflict = new Conflict(nsTile0, np0, np3, dir/2, true); // ood, right
label_apply:
{
for (Conflict conf_old:conflicts_list){
......@@ -361,7 +354,7 @@ public class Conflicts {
int dir2 = (dir1 + 5) % 8;
int np3 = neibs2[dir2]; // planes[nsTile2][np2].getNeibBest(dir2);
if ((np3 >= 0) && (np3 != np0)){
Conflict conflict = new Conflict(np0, np3, dir/2, true); // ood, right
Conflict conflict = new Conflict(nsTile0, np0, np3, dir/2, false); // ood, left
label_apply:
{
for (Conflict conf_old:conflicts_list){
......
This diff is collapsed.
......@@ -3477,7 +3477,6 @@ public class TileProcessor {
int [] conflict_resoultion_results = st.resolveMultiTriangularConflicts(
conflicts0, // int [][][] conflicts,
conflicts0_stats,
clt_parameters.plMaxEigen,
clt_parameters.plStarOrtho, // double orthoWeight,
clt_parameters.plStarDiag, // double diagonalWeight,
clt_parameters.plDblTriLoss, // double diagonalWeight,
......@@ -3486,28 +3485,10 @@ public class TileProcessor {
clt_parameters.tileX,
clt_parameters.tileY);
System.out.println("Pass "+(pass+1)+": multi_tri_results (success/failures) = "+conflict_resoultion_results[0]+" / "+conflict_resoultion_results[1]);
if ((dual_tri_results[0] == 0) &&(conflict_resoultion_results[0] == 0)) break;
}
/*
int [] conflicts1_stats = st.getNumConflicts(
conflicts0,
1); // -1); // debugLevel);
st.printConflictSummary(conflicts1_stats);
*/
Conflicts conflicts1_stats = new Conflicts(
conflicts0,
st,
-1); // debugLevel);
conflicts1_stats.printConflictSummary("Detected conflicts (all):", true,false,false);
conflicts1_stats.printConflictSummary("Detected conflicts (ortho-diag-ortho):", false, true,false);
conflicts1_stats.printConflictSummary("Detected conflicts(ortho-ortho-diag):", false, false, true);
/*
for (int pass = 0; pass < 10; pass ++) {
int [] dual_tri_results = st. resolveDualTriangularConflicts(
int [] diagonal_resoultion_results = st.resolveDiagonalTriangularConflicts(
conflicts0, // int [][][] conflicts,
conflicts0_stats,
clt_parameters.plMaxEigen,
clt_parameters.plStarOrtho, // double orthoWeight,
clt_parameters.plStarDiag, // double diagonalWeight,
clt_parameters.plDblTriLoss, // double diagonalWeight,
......@@ -3515,27 +3496,19 @@ public class TileProcessor {
1, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.println("Pass "+(pass+1)+": dual_tri_results (success/failures) = "+dual_tri_results[0]+" / "+dual_tri_results[1]);
if (dual_tri_results[0] == 0) break;
System.out.println("Pass "+(pass+1)+": resolveDiagonalTriangularConflicts (success/failures) = "+diagonal_resoultion_results[0]+" / "+diagonal_resoultion_results[1]);
if ( (dual_tri_results[0] == 0) &&
(conflict_resoultion_results[0] == 0) &&
(diagonal_resoultion_results[0] == 0)) break;
}
conflicts1_stats = st.getNumConflicts(
Conflicts conflicts1_stats = new Conflicts(
conflicts0,
st,
1); // -1); // debugLevel);
st.printConflictSummary(conflicts1_stats);
*/
/*
// re-checking conflicts (make sure update is correct)
int [][][] conflicts1r = st.detectTriangularConflicts(
1); // final int debugLevel)
int [] conflicts1r_stats = st.getNumConflicts(
conflicts1r,
-1); // debugLevel);
st.printConflictSummary(conflicts1r_stats);
*/
conflicts1_stats.printConflictSummary("Detected conflicts (all):", true,false,false);
conflicts1_stats.printConflictSummary("Detected conflicts (ortho-diag-ortho):", false, true,false);
conflicts1_stats.printConflictSummary("Detected conflicts(ortho-ortho-diag):", false, false, true);
st.testResoveTriangle(
clt_parameters.plWorstWorsening, // final double worst_worsening,
......@@ -3550,8 +3523,6 @@ public class TileProcessor {
clt_parameters.tileX,
clt_parameters.tileY);
if (clt_parameters.plSplitApply) {
while (true) {
int num_added = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment