Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
0ab422e2
Commit
0ab422e2
authored
Jun 02, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removing foreground bridges
parent
971dd284
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
889 additions
and
946 deletions
+889
-946
Conflicts.java
src/main/java/Conflicts.java
+4
-4
ConnectionCosts.java
src/main/java/ConnectionCosts.java
+6
-6
LinkPlanes.java
src/main/java/LinkPlanes.java
+16
-5
SuperTiles.java
src/main/java/SuperTiles.java
+154
-489
TileNeibs.java
src/main/java/TileNeibs.java
+366
-0
TilePlanes.java
src/main/java/TilePlanes.java
+342
-289
TileProcessor.java
src/main/java/TileProcessor.java
+1
-15
TileSurface.java
src/main/java/TileSurface.java
+0
-138
No files found.
src/main/java/Conflicts.java
View file @
0ab422e2
...
@@ -284,7 +284,7 @@ public class Conflicts {
...
@@ -284,7 +284,7 @@ public class Conflicts {
final
int
stilesY
=
(
tilesY
+
superTileSize
-
1
)/
superTileSize
;
final
int
stilesY
=
(
tilesY
+
superTileSize
-
1
)/
superTileSize
;
final
int
nStiles
=
stilesX
*
stilesY
;
final
int
nStiles
=
stilesX
*
stilesY
;
final
int
[][][]
conflicts
=
new
int
[
st
.
getPlanes
().
length
][][];
final
int
[][][]
conflicts
=
new
int
[
st
.
getPlanes
().
length
][][];
final
Tile
Surface
.
TileNeibs
tnSurface
=
st
.
getTileSurface
().
new
TileNeibs
(
stilesX
,
stilesY
);
final
Tile
Neibs
tnSurface
=
new
TileNeibs
(
stilesX
,
stilesY
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
st
.
getTileProcessor
().
threadsMax
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
st
.
getTileProcessor
().
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
...
@@ -343,7 +343,7 @@ public class Conflicts {
...
@@ -343,7 +343,7 @@ public class Conflicts {
HashMap
<
Integer
,
Integer
>
replacement_tiles
,
// null is OK
HashMap
<
Integer
,
Integer
>
replacement_tiles
,
// null is OK
int
[][][]
replacement_neibs
,
// null OK if replacement_tiles == null
int
[][][]
replacement_neibs
,
// null OK if replacement_tiles == null
double
[][][]
replacement_val_weights
,
double
[][][]
replacement_val_weights
,
Tile
Surface
.
Tile
Neibs
tnSurface
)
TileNeibs
tnSurface
)
{
{
TilePlanes
.
PlaneData
[][]
planes
=
st
.
getPlanes
();
TilePlanes
.
PlaneData
[][]
planes
=
st
.
getPlanes
();
// generate conflicts if not provided
// generate conflicts if not provided
...
@@ -405,7 +405,7 @@ public class Conflicts {
...
@@ -405,7 +405,7 @@ public class Conflicts {
HashMap
<
Integer
,
Integer
>
replacement_tiles
,
// null is OK
HashMap
<
Integer
,
Integer
>
replacement_tiles
,
// null is OK
int
[][][]
replacement_neibs
,
// null OK if replacement_tiles == null
int
[][][]
replacement_neibs
,
// null OK if replacement_tiles == null
ConnectionCosts
connectionCosts
,
ConnectionCosts
connectionCosts
,
Tile
Surface
.
Tile
Neibs
tnSurface
)
TileNeibs
tnSurface
)
{
{
TilePlanes
.
PlaneData
[][]
planes
=
st
.
getPlanes
();
TilePlanes
.
PlaneData
[][]
planes
=
st
.
getPlanes
();
// generate conflicts if not provided
// generate conflicts if not provided
...
@@ -465,7 +465,7 @@ public class Conflicts {
...
@@ -465,7 +465,7 @@ public class Conflicts {
int
nsTile0
,
int
nsTile0
,
HashMap
<
Integer
,
Integer
>
replacement_tiles
,
// null is OK - will use only planes data
HashMap
<
Integer
,
Integer
>
replacement_tiles
,
// null is OK - will use only planes data
int
[][][]
replacement_neibs
,
// null OK if replacement_tiles == null
int
[][][]
replacement_neibs
,
// null OK if replacement_tiles == null
Tile
Surface
.
Tile
Neibs
tnSurface
)
TileNeibs
tnSurface
)
{
{
TilePlanes
.
PlaneData
[][]
planes
=
st
.
getPlanes
();
TilePlanes
.
PlaneData
[][]
planes
=
st
.
getPlanes
();
ArrayList
<
Conflict
>
conflicts_list
=
new
ArrayList
<
Conflict
>();
ArrayList
<
Conflict
>
conflicts_list
=
new
ArrayList
<
Conflict
>();
...
...
src/main/java/ConnectionCosts.java
View file @
0ab422e2
...
@@ -28,7 +28,7 @@ import java.util.HashSet;
...
@@ -28,7 +28,7 @@ import java.util.HashSet;
public
class
ConnectionCosts
{
public
class
ConnectionCosts
{
TilePlanes
.
PlaneData
[][]
planes
=
null
;
TilePlanes
.
PlaneData
[][]
planes
=
null
;
boolean
preferDisparity
=
false
;
boolean
preferDisparity
=
false
;
Tile
Surface
.
Tile
Neibs
tnSurface
;
TileNeibs
tnSurface
;
double
orthoWeight
;
double
orthoWeight
;
double
diagonalWeight
;
double
diagonalWeight
;
double
starPwr
;
// Divide cost by number of connections to this power
double
starPwr
;
// Divide cost by number of connections to this power
...
@@ -57,7 +57,7 @@ public class ConnectionCosts {
...
@@ -57,7 +57,7 @@ public class ConnectionCosts {
double
starValPwr
,
// Raise value of each tile before averaging
double
starValPwr
,
// Raise value of each tile before averaging
int
steps
,
int
steps
,
TilePlanes
.
PlaneData
[][]
planes
,
TilePlanes
.
PlaneData
[][]
planes
,
Tile
Surface
.
Tile
Neibs
tnSurface
,
TileNeibs
tnSurface
,
boolean
preferDisparity
)
boolean
preferDisparity
)
{
{
this
.
planes
=
planes
;
this
.
planes
=
planes
;
...
@@ -481,7 +481,7 @@ public class ConnectionCosts {
...
@@ -481,7 +481,7 @@ public class ConnectionCosts {
double
diagonalWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starPwr
,
// Divide cost by number of connections to this power
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
Tile
Surface
.
Tile
Neibs
tnSurface
,
TileNeibs
tnSurface
,
boolean
preferDisparity
,
boolean
preferDisparity
,
int
debugLevel
)
int
debugLevel
)
{
{
...
@@ -506,7 +506,7 @@ public class ConnectionCosts {
...
@@ -506,7 +506,7 @@ public class ConnectionCosts {
double
diagonalWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starPwr
,
// Divide cost by number of connections to this power
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
Tile
Surface
.
Tile
Neibs
tnSurface
,
TileNeibs
tnSurface
,
boolean
preferDisparity
,
boolean
preferDisparity
,
int
debugLevel
)
int
debugLevel
)
{
{
...
@@ -566,7 +566,7 @@ public class ConnectionCosts {
...
@@ -566,7 +566,7 @@ public class ConnectionCosts {
double
diagonalWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starPwr
,
// Divide cost by number of connections to this power
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
Tile
Surface
.
Tile
Neibs
tnSurface
,
TileNeibs
tnSurface
,
boolean
preferDisparity
,
boolean
preferDisparity
,
int
debugLevel
)
int
debugLevel
)
{
{
...
@@ -594,7 +594,7 @@ public class ConnectionCosts {
...
@@ -594,7 +594,7 @@ public class ConnectionCosts {
double
diagonalWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starPwr
,
// Divide cost by number of connections to this power
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
Tile
Surface
.
Tile
Neibs
tnSurface
,
TileNeibs
tnSurface
,
boolean
preferDisparity
,
boolean
preferDisparity
,
int
debugLevel
)
int
debugLevel
)
{
{
...
...
src/main/java/LinkPlanes.java
View file @
0ab422e2
...
@@ -813,6 +813,17 @@ public class LinkPlanes {
...
@@ -813,6 +813,17 @@ public class LinkPlanes {
ImageDtt
.
startAndJoin
(
threads
);
ImageDtt
.
startAndJoin
(
threads
);
}
}
/**
* Merge the supertile planes with agreeing neighbors, non-exclusively (no considering other planes
* of the same supertile. Start with the best fit, then goes to lower quality, until the individual
* merge quality falls below scaled quality of the best, pre-set minimum or the merged plane becomes
* too thick
* Separately calculates merged weighted plane and with equal weights of the neighbors
* @param planes array of plane instances for the same supertile
* @param debugLevel
* @param dbg_X
* @param dbg_Y
*/
public
void
setNonExclusive
(
public
void
setNonExclusive
(
final
TilePlanes
.
PlaneData
[][]
planes
,
final
TilePlanes
.
PlaneData
[][]
planes
,
final
int
debugLevel
,
final
int
debugLevel
,
...
@@ -834,7 +845,7 @@ public class LinkPlanes {
...
@@ -834,7 +845,7 @@ public class LinkPlanes {
// final int debug_stile = 9 * stilesX + 26;
// final int debug_stile = 9 * stilesX + 26;
final
int
debug_stile
=
dbg_Y
*
stilesX
+
dbg_X
;
final
int
debug_stile
=
dbg_Y
*
stilesX
+
dbg_X
;
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
st
.
tileProcessor
.
threadsMax
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
(
debugLevel
>
1
)?
1
:
st
.
tileProcessor
.
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
...
@@ -2426,7 +2437,7 @@ public class LinkPlanes {
...
@@ -2426,7 +2437,7 @@ public class LinkPlanes {
final
int
stilesX
=
(
tilesX
+
superTileSize
-
1
)/
superTileSize
;
final
int
stilesX
=
(
tilesX
+
superTileSize
-
1
)/
superTileSize
;
final
int
stilesY
=
(
tilesY
+
superTileSize
-
1
)/
superTileSize
;
final
int
stilesY
=
(
tilesY
+
superTileSize
-
1
)/
superTileSize
;
final
int
nStiles
=
stilesX
*
stilesY
;
final
int
nStiles
=
stilesX
*
stilesY
;
final
Tile
Surface
.
TileNeibs
tnSurface
=
st
.
tileSurface
.
new
TileNeibs
(
stilesX
,
stilesY
);
final
Tile
Neibs
tnSurface
=
new
TileNeibs
(
stilesX
,
stilesY
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
st
.
tileProcessor
.
threadsMax
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
st
.
tileProcessor
.
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
...
@@ -2441,7 +2452,7 @@ public class LinkPlanes {
...
@@ -2441,7 +2452,7 @@ public class LinkPlanes {
starValPwr
,
//double starValPwr, // Raise value of each tile before averaging
starValPwr
,
//double starValPwr, // Raise value of each tile before averaging
steps
,
// int steps,
steps
,
// int steps,
planes
,
// TilePlanes.PlaneData [][] planes,
planes
,
// TilePlanes.PlaneData [][] planes,
tnSurface
,
// Tile
Surface.Tile
Neibs tnSurface,
tnSurface
,
// TileNeibs tnSurface,
preferDisparity
);
// boolean preferDisparity)
preferDisparity
);
// boolean preferDisparity)
int
[]
mod_supertiles
=
new
int
[
1
];
int
[]
mod_supertiles
=
new
int
[
1
];
for
(
int
nsTile
=
ai
.
getAndIncrement
();
nsTile
<
nStiles
;
nsTile
=
ai
.
getAndIncrement
())
{
for
(
int
nsTile
=
ai
.
getAndIncrement
();
nsTile
<
nStiles
;
nsTile
=
ai
.
getAndIncrement
())
{
...
@@ -2484,7 +2495,7 @@ public class LinkPlanes {
...
@@ -2484,7 +2495,7 @@ public class LinkPlanes {
// final int tileSize = tileProcessor.getTileSize();
// final int tileSize = tileProcessor.getTileSize();
final
int
stilesX
=
(
tilesX
+
superTileSize
-
1
)/
superTileSize
;
final
int
stilesX
=
(
tilesX
+
superTileSize
-
1
)/
superTileSize
;
final
int
stilesY
=
(
tilesY
+
superTileSize
-
1
)/
superTileSize
;
final
int
stilesY
=
(
tilesY
+
superTileSize
-
1
)/
superTileSize
;
final
Tile
Surface
.
TileNeibs
tnSurface
=
st
.
tileSurface
.
new
TileNeibs
(
stilesX
,
stilesY
);
final
Tile
Neibs
tnSurface
=
new
TileNeibs
(
stilesX
,
stilesY
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
st
.
tileProcessor
.
threadsMax
);
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
st
.
tileProcessor
.
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
...
@@ -2499,7 +2510,7 @@ public class LinkPlanes {
...
@@ -2499,7 +2510,7 @@ public class LinkPlanes {
starValPwr
,
//double starValPwr, // Raise value of each tile before averaging
starValPwr
,
//double starValPwr, // Raise value of each tile before averaging
steps
,
// int steps,
steps
,
// int steps,
planes
,
// TilePlanes.PlaneData [][] planes,
planes
,
// TilePlanes.PlaneData [][] planes,
tnSurface
,
// Tile
Surface.Tile
Neibs tnSurface,
tnSurface
,
// TileNeibs tnSurface,
preferDisparity
);
// boolean preferDisparity)
preferDisparity
);
// boolean preferDisparity)
int
[]
supertiles
=
new
int
[
1
];
int
[]
supertiles
=
new
int
[
1
];
for
(
int
isTile
=
ai
.
getAndIncrement
();
isTile
<
mod_supertiles
.
length
;
isTile
=
ai
.
getAndIncrement
())
{
for
(
int
isTile
=
ai
.
getAndIncrement
();
isTile
<
mod_supertiles
.
length
;
isTile
=
ai
.
getAndIncrement
())
{
...
...
src/main/java/SuperTiles.java
View file @
0ab422e2
This diff is collapsed.
Click to expand it.
src/main/java/TileNeibs.java
0 → 100644
View file @
0ab422e2
This diff is collapsed.
Click to expand it.
src/main/java/TilePlanes.java
View file @
0ab422e2
This diff is collapsed.
Click to expand it.
src/main/java/TileProcessor.java
View file @
0ab422e2
...
@@ -3386,7 +3386,7 @@ public class TileProcessor {
...
@@ -3386,7 +3386,7 @@ public class TileProcessor {
LinkPlanes
lp
=
new
LinkPlanes
(
clt_parameters
,
st
);
LinkPlanes
lp
=
new
LinkPlanes
(
clt_parameters
,
st
);
// try to merge multiple times
// try to merge multiple times
int
max_num_merge_try
=
5
;
int
max_num_merge_try
=
8
;
TilePlanes
.
PlaneData
[][][]
dbg_orig_planes
=
new
TilePlanes
.
PlaneData
[
max_num_merge_try
][][];
TilePlanes
.
PlaneData
[][][]
dbg_orig_planes
=
new
TilePlanes
.
PlaneData
[
max_num_merge_try
][][];
for
(
int
num_merge_try
=
0
;
num_merge_try
<
max_num_merge_try
;
num_merge_try
++){
for
(
int
num_merge_try
=
0
;
num_merge_try
<
max_num_merge_try
;
num_merge_try
++){
...
@@ -3467,20 +3467,6 @@ public class TileProcessor {
...
@@ -3467,20 +3467,6 @@ public class TileProcessor {
clt_parameters
.
tileX
,
clt_parameters
.
tileX
,
clt_parameters
.
tileY
);
clt_parameters
.
tileY
);
// System.out.println("merge_cost_data.length = " + merge_cost_data.length);
// System.out.println("merge_cost_data.length = " + merge_cost_data.length);
/*
// double [][][][][][] merge_cost_data_eq =
lp.costSameTileConnections(
true, // final boolean ignore_weights,
1.8, // final double threshold_worst,
1000.0, //final double threshold_world_worst,
st.planes, // ffinal TilePlanes.PlaneData [][] planes,
merge_candidates, // final int [][][] merge_candidates,
plane_nooverlaps, // final boolean [][][] valid_candidates, // will be updated
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// System.out.println("merge_cost_data_eq.length = " + merge_cost_data_eq.length);
*/
int
[][][]
merge_groups
=
lp
.
extractMergeSameTileGroups
(
int
[][][]
merge_groups
=
lp
.
extractMergeSameTileGroups
(
st
.
planes
,
// final TilePlanes.PlaneData [][] planes,
st
.
planes
,
// final TilePlanes.PlaneData [][] planes,
merge_candidates
,
// final int [][][] merge_candidates,
merge_candidates
,
// final int [][][] merge_candidates,
...
...
src/main/java/TileSurface.java
View file @
0ab422e2
...
@@ -235,144 +235,6 @@ public class TileSurface {
...
@@ -235,144 +235,6 @@ public class TileSurface {
}
}
public
class
TileNeibs
{
int
sizeX
;
int
sizeY
;
public
int
dirs
=
8
;
public
TileNeibs
(
int
size
){
this
.
sizeX
=
size
;
this
.
sizeY
=
size
;
}
public
TileNeibs
(
int
sizeX
,
int
sizeY
){
this
.
sizeX
=
sizeX
;
this
.
sizeY
=
sizeY
;
}
public
int
numNeibs
()
// TODO: make configurable to
{
return
dirs
;
}
public
int
opposite
(
int
dir
){
return
(
dir
+
dirs
/
2
)
%
dirs
;
}
/**
* Get x,y pair from index
* @param indx element index
* @return array of {x,y}
*/
int
[]
getXY
(
int
indx
)
{
int
[]
xy
=
{
indx
%
sizeX
,
indx
/
sizeX
};
return
xy
;
}
/**
* Get element index from x and y
* @param x horizontal position
* @param y vertical position
* @return element linescan index
*/
int
getIndex
(
int
x
,
int
y
){
return
y
*
sizeX
+
x
;
}
/**
* Get 2d element index after step N, NE, ... NW. Returns -1 if leaving array
* @param indx start index
* @param dir step direction (CW from up)
* @return new index or -1 if leaving
*/
int
getNeibIndex
(
int
indx
,
int
dir
)
{
int
y
=
indx
/
sizeX
;
int
x
=
indx
%
sizeX
;
if
(
dir
<
0
)
return
indx
;
switch
(
dir
%
dirs
){
case
0
:
return
(
y
==
0
)
?
-
1
:
(
indx
-
sizeX
);
case
1
:
return
((
y
==
0
)
||
(
x
==
(
sizeX
-
1
)))
?
-
1
:
(
indx
-
sizeX
+
1
);
case
2
:
return
(
(
x
==
(
sizeX
-
1
)))
?
-
1
:
(
indx
+
1
);
case
3
:
return
((
y
==
(
sizeY
-
1
))
||
(
x
==
(
sizeX
-
1
)))
?
-
1
:
(
indx
+
sizeX
+
1
);
case
4
:
return
((
y
==
(
sizeY
-
1
))
)
?
-
1
:
(
indx
+
sizeX
);
case
5
:
return
((
y
==
(
sizeY
-
1
))
||
(
x
==
0
))
?
-
1
:
(
indx
+
sizeX
-
1
);
case
6
:
return
(
(
x
==
0
))
?
-
1
:
(
indx
-
1
);
case
7
:
return
((
y
==
0
)
||
(
x
==
0
))
?
-
1
:
(
indx
-
sizeX
-
1
);
default
:
return
indx
;
}
}
/**
* Return tile segment for 50% overlap. -1 - center, 0 N, 1 - NE,... 7 - NW
* @param indx element index
* @return which of the 9 areas this element belongs
*/
int
getSegment
(
int
indx
)
{
int
s1x
=
sizeX
/
4
;
int
s3x
=
3
*
sizeX
/
4
;
int
s1y
=
sizeY
/
4
;
int
s3y
=
3
*
sizeY
/
4
;
int
x
=
indx
%
sizeX
;
int
y
=
indx
/
sizeX
;
boolean
up
=
y
<
s1y
;
boolean
down
=
y
>=
s3y
;
boolean
left
=
x
<
s1x
;
boolean
right
=
x
>=
s3x
;
if
(
up
){
if
(
left
)
return
7
;
if
(
right
)
return
1
;
return
0
;
}
if
(
down
){
if
(
left
)
return
5
;
if
(
right
)
return
3
;
return
4
;
}
if
(
left
)
return
6
;
if
(
right
)
return
2
;
return
-
1
;
}
/**
* Find if the step leaves the center half of all area
* @param indx start point
* @param dir direction
* @return direction to the new tile (assuming 50% overlap) or -1 if did not cross the border
*/
int
leaveOvderlapedCenter
(
int
indx
,
int
dir
)
{
int
segm
=
getSegment
(
indx
);
int
indx1
=
getNeibIndex
(
indx
,
dir
);
if
(
indx1
<
0
)
{
return
-
1
;
// should not happen
}
int
segm1
=
getSegment
(
indx1
);
if
(
segm1
==
segm
)
return
-
1
;
if
(
segm
==
-
1
)
return
segm1
;
int
[][]
dxy
=
{
{
0
,
0
},
{-
1
,
0
},
{-
1
,
1
},
{
0
,
1
},
{
1
,
1
},
{
1
,
0
},
{
1
,-
1
},
{
0
,-
1
},
{-
1
,-
1
}};
int
dx
=
dxy
[
segm1
+
1
][
1
]
-
dxy
[
segm
+
1
][
1
];
int
dy
=
dxy
[
segm1
+
1
][
0
]
-
dxy
[
segm
+
1
][
0
];
for
(
int
dp1
=
0
;
dp1
<=
8
;
dp1
++)
{
int
sdx
=
(
dx
>
0
)
?
1
:
(
(
dx
<
0
)
?
-
1
:
0
);
int
sdy
=
(
dy
>
0
)
?
1
:
(
(
dy
<
0
)
?
-
1
:
0
);
if
((
dxy
[
dp1
][
0
]
==
sdy
)
&&
(
dxy
[
dp1
][
1
]
==
sdx
)){
return
dp1
-
1
;
}
}
return
-
1
;
// should not happen
}
}
public
int
getNStileDir
(
public
int
getNStileDir
(
int
nsTile
,
int
nsTile
,
int
dir
)
int
dir
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment