Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hqr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
hqr
Commits
941f63d9
Commit
941f63d9
authored
7 years ago
by
BOUCHERIE Raphael
Browse files
Options
Downloads
Patches
Plain Diff
the lines are now drawn during treewalk, factorized part of the code
parent
18f459c8
No related branches found
No related tags found
1 merge request
!5
Print tree
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/treewalk.c
+31
-13
31 additions, 13 deletions
src/treewalk.c
testings/testing_treedraw.c
+2
-13
2 additions, 13 deletions
testings/testing_treedraw.c
with
33 additions
and
26 deletions
src/treewalk.c
+
31
−
13
View file @
941f63d9
...
...
@@ -19,6 +19,29 @@
#include
<stdio.h>
#include
<assert.h>
void
draw_horizontal_line
(
int
pivot
,
int
k
,
FILE
*
tree
,
int
size
,
int
*
tiles
,
int
killed
){
int
y
,
ordinate1
,
ordinate2
,
absciss1
,
absciss2
,
absciss3
,
absciss4
;
ordinate1
=
size
+
size
*
killed
;
ordinate2
=
size
+
size
*
pivot
;
absciss1
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
killed
];
absciss3
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
pivot
];
/* Increasing the step */
y
=
libhqr_imax
(
tiles
[
killed
],
tiles
[
pivot
])
+
1
;
tiles
[
killed
]
=
tiles
[
pivot
]
=
y
;
absciss2
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
killed
];
absciss4
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
pivot
];
libhqr_drawline
(
absciss1
,
ordinate1
,
absciss2
,
ordinate1
,
k
,
tree
);
libhqr_drawline
(
absciss3
,
ordinate2
,
absciss4
,
ordinate2
,
k
,
tree
);
}
void
draw_vertical_line
(
int
pivot
,
int
k
,
FILE
*
tree
,
int
size
,
int
*
tiles
,
int
killed
){
int
absciss
,
ordinate1
,
ordinate2
;
absciss
=
size
+
size
*
tiles
[
killed
];
ordinate1
=
size
+
size
*
killed
;
ordinate2
=
size
+
size
*
pivot
;
libhqr_drawline
(
absciss
,
ordinate1
,
absciss
,
ordinate2
,
k
,
tree
);
}
/****************************************************
* LIBHQR_TREEWALK
***************************************************/
...
...
@@ -35,6 +58,12 @@
* @param[in] tiles
* Table stocking the tiles and their step
*
* @param[in] tree
* File where the tree is drawn
*
* @param[in] size
* Paramter for the size of the drawing
*
*/
void
libhqr_treewalk
(
const
libhqr_tree_t
*
qrtree
,
int
k
,
int
*
tiles
,
FILE
*
tree
,
int
size
)
{
...
...
@@ -43,7 +72,6 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *tree,
int
pivot
=
k
;
libhqr_queue_tile_t
*
tt
=
libhqr_queue_tile_new
();
libhqr_queue_tile_t
*
ts
=
libhqr_queue_tile_new
();
int
y
,
ordinate1
,
ordinate2
,
ordinate3
,
ordinate4
,
absciss1
,
absciss2
,
absciss3
,
absciss4
;
libhqr_queue_tile_push
(
&
tt
,
k
);
while
(
tt
)
...
...
@@ -75,18 +103,8 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *tree,
printf
(
"POP TS: %d
\n
"
,
tsid
);
printf
(
"Call function on (%d, %d)
\n
"
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
);
/* Drawing the horizontal lines */
ordinate1
=
ordinate2
=
size
+
size
*
tsid
;
ordinate3
=
ordinate4
=
size
+
size
*
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
);
absciss1
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
tsid
];
absciss3
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
)];
/* Increasing the step */
y
=
libhqr_imax
(
tiles
[
tsid
],
tiles
[
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
)])
+
1
;
tiles
[
tsid
]
=
tiles
[
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
)]
=
y
;
absciss2
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
tsid
];
absciss4
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
)];
libhqr_drawline
(
absciss1
,
ordinate1
,
absciss2
,
ordinate2
,
k
,
tree
);
libhqr_drawline
(
absciss3
,
ordinate3
,
absciss4
,
ordinate4
,
k
,
tree
);
draw_horizontal_line
(
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
k
,
tree
,
size
,
tiles
,
tsid
);
draw_vertical_line
(
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
k
,
tree
,
size
,
tiles
,
tsid
);
tsid
=
libhqr_queue_tile_head
(
&
ts
);
}
pivot
=
p
=
ttid
;
...
...
This diff is collapsed.
Click to expand it.
testings/testing_treedraw.c
+
2
−
13
View file @
941f63d9
...
...
@@ -30,7 +30,7 @@ main(int argc, char ** argv)
{
libhqr_tree_t
qrtree
;
libhqr_tiledesc_t
matrix
;
int
maxMN
,
absciss1
,
ordinate1
,
absciss2
,
ordinate2
,
k
,
i
,
j
;
int
maxMN
,
absciss1
,
ordinate1
,
k
,
i
,
j
;
int
*
tiles
;
matrix
.
nodes
=
1
;
matrix
.
p
=
1
;
...
...
@@ -45,25 +45,14 @@ main(int argc, char ** argv)
FILE
*
tree
=
fopen
(
"tree.svg"
,
"w+"
);
libhqr_writeheader
(
tree
);
for
(
k
=
0
;
k
<
3
;
k
++
){
/* Drawing the
horizontal
lines */
/* Drawing the lines */
libhqr_treewalk
(
&
qrtree
,
k
,
tiles
,
tree
,
SIZE
);
/* Drawing the vertical lines */
for
(
i
=
k
;
i
<
maxMN
;
i
++
){
if
(
i
>
0
){
absciss1
=
absciss2
=
SIZE
+
SIZE
*
tiles
[
i
];
ordinate1
=
SIZE
+
SIZE
*
i
;
ordinate2
=
SIZE
+
SIZE
*
(
qrtree
.
currpiv
(
&
qrtree
,
k
,
i
));
libhqr_drawline
(
absciss1
,
ordinate1
,
absciss2
,
ordinate2
,
k
,
tree
);
}
}
/* Drawing the rectangles */
for
(
i
=
k
+
1
;
i
<
maxMN
;
i
++
){
absciss1
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
tiles
[
i
];
ordinate1
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
i
;
libhqr_drawTS
(
absciss1
,
ordinate1
,
WIDTH
,
HEIGHT
,
k
,
tree
);
j
=
qrtree
.
currpiv
(
&
qrtree
,
k
,
i
);
absciss1
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
tiles
[
i
];
ordinate1
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
j
;
libhqr_drawTT
(
absciss1
,
ordinate1
,
WIDTH
,
HEIGHT
,
k
,
tree
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment