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
86923d9a
Commit
86923d9a
authored
7 years ago
by
BOUCHERIE Raphael
Browse files
Options
Downloads
Patches
Plain Diff
factorized the rectangle drawing, moved some functions
parent
1f3bde00
No related branches found
No related tags found
1 merge request
!5
Print tree
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/libdraw.h
+3
-0
3 additions, 0 deletions
include/libdraw.h
include/libhqr.h
+4
-1
4 additions, 1 deletion
include/libhqr.h
src/treewalk.c
+23
-18
23 additions, 18 deletions
src/treewalk.c
testings/testing_treedraw.c
+3
-22
3 additions, 22 deletions
testings/testing_treedraw.c
with
33 additions
and
41 deletions
include/libdraw.h
+
3
−
0
View file @
86923d9a
...
...
@@ -18,6 +18,9 @@
#define _LIBDRAW_H_
#include
<common.h>
#define WIDTH 50
#define HEIGHT 50
#define SIZE 100
BEGIN_C_DECLS
...
...
This diff is collapsed.
Click to expand it.
include/libhqr.h
+
4
−
1
View file @
86923d9a
...
...
@@ -194,7 +194,10 @@ void libhqr_hqr_finalize( libhqr_tree_t *qrtree );
* function for treewalk
*/
void
libhqr_treewalk
(
const
libhqr_tree_t
*
qrtree
,
int
k
,
int
*
tiles
,
FILE
*
file
,
int
size
);
void
libhqr_treewalk
(
const
libhqr_tree_t
*
qrtree
,
int
k
,
int
*
tiles
,
FILE
*
file
);
void
draw_rectangle
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
void
draw_horizontal_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
void
draw_vertical_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
/*
* Debugging functions
...
...
This diff is collapsed.
Click to expand it.
src/treewalk.c
+
23
−
18
View file @
86923d9a
...
...
@@ -25,33 +25,41 @@
* p - annihilator
* m - tile eliminated
* file - File where the lines are drawn
* size - Size parameter of the drawing
* tiles - table stocking the tiles
*/
void
draw_horizontal_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
,
int
size
){
void
draw_horizontal_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
){
int
y
,
ordinate1
,
ordinate2
,
absciss1
,
absciss2
,
absciss3
,
absciss4
;
ordinate1
=
size
+
size
*
m
;
ordinate2
=
size
+
size
*
p
;
absciss1
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
m
];
absciss3
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
p
];
ordinate1
=
SIZE
+
SIZE
*
m
;
ordinate2
=
SIZE
+
SIZE
*
p
;
absciss1
=
(
SIZE
+
(
SIZE
/
4
))
+
SIZE
*
tiles
[
m
];
absciss3
=
(
SIZE
+
(
SIZE
/
4
))
+
SIZE
*
tiles
[
p
];
/* Increasing the step */
y
=
libhqr_imax
(
tiles
[
m
],
tiles
[
p
])
+
1
;
tiles
[
m
]
=
tiles
[
p
]
=
y
;
absciss2
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
m
];
absciss4
=
(
size
+
(
size
/
4
))
+
size
*
tiles
[
p
];
absciss2
=
(
SIZE
+
(
SIZE
/
4
))
+
SIZE
*
tiles
[
m
];
absciss4
=
(
SIZE
+
(
SIZE
/
4
))
+
SIZE
*
tiles
[
p
];
libhqr_drawline
(
absciss1
,
ordinate1
,
absciss2
,
ordinate1
,
k
,
file
);
libhqr_drawline
(
absciss3
,
ordinate2
,
absciss4
,
ordinate2
,
k
,
file
);
}
void
draw_vertical_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
,
int
size
){
void
draw_vertical_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
){
int
absciss
,
ordinate1
,
ordinate2
;
absciss
=
size
+
size
*
tiles
[
m
];
ordinate1
=
size
+
size
*
m
;
ordinate2
=
size
+
size
*
p
;
absciss
=
SIZE
+
SIZE
*
tiles
[
m
];
ordinate1
=
SIZE
+
SIZE
*
m
;
ordinate2
=
SIZE
+
SIZE
*
p
;
libhqr_drawline
(
absciss
,
ordinate1
,
absciss
,
ordinate2
,
k
,
file
);
}
void
draw_rectangle
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
){
int
absciss
,
ordinate
;
absciss
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
tiles
[
m
];
ordinate
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
m
;
libhqr_drawTS
(
absciss
,
ordinate
,
WIDTH
,
HEIGHT
,
k
,
file
);
ordinate
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
p
;
libhqr_drawTT
(
absciss
,
ordinate
,
WIDTH
,
HEIGHT
,
k
,
file
);
}
/****************************************************
* LIBHQR_TREEWALK
***************************************************/
...
...
@@ -71,11 +79,8 @@ void draw_vertical_line(int k, int p, int m, int *tiles, FILE *file, int size){
* @param[in] file
* 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
*
file
,
int
size
)
void
libhqr_treewalk
(
const
libhqr_tree_t
*
qrtree
,
int
k
,
int
*
tiles
,
FILE
*
file
)
{
int
tsid
=
-
1
,
ttid
=
-
1
;
int
p
=
k
;
...
...
@@ -113,8 +118,8 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *file,
printf
(
"POP TS: %d
\n
"
,
tsid
);
printf
(
"Call function on (%d, %d)
\n
"
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
);
draw_horizontal_line
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
,
tiles
,
file
,
size
);
draw_vertical_line
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
,
tiles
,
file
,
size
);
draw_horizontal_line
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
,
tiles
,
file
);
draw_vertical_line
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
,
tiles
,
file
);
tsid
=
libhqr_queue_tile_head
(
&
ts
);
}
pivot
=
p
=
ttid
;
...
...
This diff is collapsed.
Click to expand it.
testings/testing_treedraw.c
+
3
−
22
View file @
86923d9a
...
...
@@ -21,16 +21,12 @@
#include
"libdraw.h"
#include
"libhqr.h"
#define WIDTH 50
#define HEIGHT 50
#define SIZE 100
int
main
(
int
argc
,
char
**
argv
)
{
libhqr_tree_t
qrtree
;
libhqr_tiledesc_t
matrix
;
int
maxMN
,
absciss1
,
ordinate1
,
k
,
i
,
j
;
int
maxMN
,
k
,
i
;
int
*
tiles
;
matrix
.
nodes
=
1
;
matrix
.
p
=
1
;
...
...
@@ -46,25 +42,10 @@ main(int argc, char ** argv)
libhqr_writeheader
(
tree
);
for
(
k
=
0
;
k
<
3
;
k
++
){
/* Drawing the lines */
libhqr_treewalk
(
&
qrtree
,
k
,
tiles
,
tree
,
SIZE
);
libhqr_treewalk
(
&
qrtree
,
k
,
tiles
,
tree
);
/* Drawing the rectangles */
for
(
i
=
k
+
1
;
i
<
maxMN
;
i
++
){
if
(
qrtree
.
gettype
(
&
qrtree
,
k
,
i
)
==
0
){
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
);
ordinate1
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
j
;
libhqr_drawTT
(
absciss1
,
ordinate1
,
WIDTH
,
HEIGHT
,
k
,
tree
);
}
else
{
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
);
ordinate1
=
((
SIZE
*
3
)
/
4
)
+
SIZE
*
j
;
libhqr_drawTT
(
absciss1
,
ordinate1
,
WIDTH
,
HEIGHT
,
k
,
tree
);
}
draw_rectangle
(
k
,
qrtree
.
currpiv
(
&
qrtree
,
k
,
i
),
i
,
tiles
,
tree
);
}
}
libhqr_writeend
(
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