File "clean02.il"
Full Path: /home/analogde/www/VirtualKeyboardSample/SKILL/clean02.il
File size: 3.7 KB
MIME-type: text/plain
Charset: utf-8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure(fonction_ordre()
coord_concatener = '()
path_ordre = '()
cv = geGetEditCellView()
win_id = getCurrentWindow()
segments = geGetSelSet()
for(i 0 length(segments)-1
points='()
id = nth(i segments)
points = id~>points
nb_points = id~>nPoints
for(j 0 nb_points-1-1
coord_concatener = append1(coord_concatener nth(j points))
)
; dernier point du dernier segment
if(i == length(segments)-1 then
coord_concatener = append1(coord_concatener nth(nb_points-1 points))
)
)
coord_concatener = '()
for(i 0 length(segments)-1
points='()
id = nth(i segments)
points = id~>points
nb_points = id~>nPoints
coord_concatener = append1(coord_concatener car(points))
coord_concatener= append1(coord_concatener cadr(points))
)
;; rechercher x le plus petit et y le plus petit
liste_x = '()
liste_y = '()
for(i 0 length(coord_concatener)-1
liste_x = append1(liste_x car(nth(i coord_concatener)))
liste_y = append1(liste_y cadr(nth(i coord_concatener)))
)
mini_x = minimum(liste_x)
maxi_x = maximum(liste_x)
mini_y = minimum(liste_y)
maxi_y = maximum(liste_y)
for(i 0 length(segments)-1
test = leIsPointInsideFig(nth(i segments) list(mini_x mini_y))
if(test == t then
id_path_detecter = nth(i segments)
path_ordre = append1(path_ordre id_path_detecter)
)
)
tmp = '()
tmp = remove(id_path_detecter segments)
;; replacer les points dans le sens de parcours
points = id_path_detecter~>points
n_pts = id_path_detecter~>nPoints
test = equal(nth(0 points) list(mini_x mini_y) )
if(test == t then
rien = 0
)
test = equal(nth(n_pts-1 points) list(mini_x mini_y) )
if(test == t then
;; faire un reverse de la liste des points
reverse_pts = reverse(points)
id_path_detecter~>points = reverse_pts
)
for(i 0 length(tmp)-1
id_search = id_path_detecter
bBox = id_search~>bBox
figList = dbProduceOverlap(cv bBox)
figList = remove(id_search figList)
if(length(figList) == 1 then
id_path_detecter = nth(0 figList)
path_ordre = append1(path_ordre id_path_detecter)
else
un = nth(0 figList)
res = setof( x path_ordre (x == un ) )
if(res == nil then
id_path_detecter = nth(0 figList)
path_ordre = append1(path_ordre id_path_detecter)
)
deux = nth(1 figList)
res = setof( x path_ordre (x == deux ) )
if(res == nil then
id_path_detecter = nth(1 figList)
path_ordre = append1(path_ordre id_path_detecter)
)
)
)
liste_points = '()
first = list(mini_x mini_y)
liste_points = append1(liste_points first )
for(i 0 length(path_ordre)-1-1
id1 = nth(i path_ordre)
p1 = car(id1~>points)
p2 = cadr(id1~>points)
xa = car(p1)
ya = cadr(p1)
xb = car(p2)
yb = cadr(p2)
id2 = nth(i+1 path_ordre)
p1 = car(id2~>points)
p2 = cadr(id2~>points)
xc = car(p1)
yc = cadr(p1)
xd = car(p2)
yd = cadr(p2)
tampon = '()
tampon = calculer_intersection_segment(xa ya xb yb xc yc xd yd)
liste_points = append1(liste_points tampon)
)
last_path = nth(0 reverse(path_ordre))
p1 = car(last_path~>points)
p2 = cadr(last_path~>points)
last_point = nth(0 reverse(liste_points))
test = equal(p1 last_point )
if(test == t then
liste_points = append1(liste_points p2)
)
test = equal(p2 last_point )
if(test == t then
liste_points = append1(liste_points p1)
)
printf("**** : %L \n" liste_points )
printf("**** : %L \n" path_ordre)
)