Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
predicats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vincent Nivoliers
predicats
Commits
f5511ce2
Commit
f5511ce2
authored
Nov 18, 2019
by
Vincent Nivoliers
Browse files
Options
Downloads
Patches
Plain Diff
adding hull code
parent
d53dec64
No related branches found
No related tags found
No related merge requests found
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Code/Makefile
+6
-3
6 additions, 3 deletions
Code/Makefile
Code/hull.cpp
+143923
-0
143923 additions, 0 deletions
Code/hull.cpp
Code/svg.cpp
+193
-0
193 additions, 0 deletions
Code/svg.cpp
Code/svg.hpp
+99
-0
99 additions, 0 deletions
Code/svg.hpp
with
144221 additions
and
3 deletions
Code/Makefile
+
6
−
3
View file @
f5511ce2
all
:
precision
#
hull
all
:
precision hull
precision
:
precision.cpp
g++
-g
-Wall
precision.cpp
-o
precision
#hull: hull.cpp svg.cpp
# g++ -g -Wall hull.cpp svg.cpp -o hull
hull
:
hull.cpp svg.cpp
g++
-g
-Wall
hull.cpp svg.cpp
-o
hull
clean
:
rm
-f
precision hull
This diff is collapsed.
Click to expand it.
Code/hull.cpp
0 → 100644
+
143923
−
0
View file @
f5511ce2
This diff is collapsed.
Click to expand it.
Code/svg.cpp
0 → 100644
+
193
−
0
View file @
f5511ce2
// @licstart revoropt
// This file is part of Revoropt, a library for the computation and
// optimization of restricted Voronoi diagrams.
//
// Copyright (C) 2013 Vincent Nivoliers <vincent.nivoliers@univ-lyon1.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// @licend revoropt
#include
"svg.hpp"
#include
<iostream>
#include
<fstream>
#include
<algorithm>
void
SvgPad
::
solid_point
(
int
x
,
int
y
)
{
file_
<<
"<circle "
<<
"cx=
\"
"
<<
x
<<
"
\"
"
<<
"cy=
\"
"
<<
y
<<
"
\"
"
<<
"r=
\"
8
\"
"
<<
"fill=
\"
rgb("
<<
fill_
[
0
]
<<
", "
<<
fill_
[
1
]
<<
", "
<<
fill_
[
2
]
<<
")
\"
"
<<
"/>"
<<
std
::
endl
;
}
void
SvgPad
::
solid_point
(
double
x
,
double
y
)
{
solid_point
(
scalex
(
x
),
scaley
(
y
))
;
}
void
SvgPad
::
contour_point
(
int
x
,
int
y
)
{
file_
<<
"<circle "
<<
"cx=
\"
"
<<
x
<<
"
\"
"
<<
"cy=
\"
"
<<
y
<<
"
\"
"
<<
"r=
\"
12
\"
"
<<
"stroke=
\"
rgb("
<<
stroke_
[
0
]
<<
", "
<<
stroke_
[
1
]
<<
", "
<<
stroke_
[
2
]
<<
")
\"
"
<<
"stroke-width=
\"
2
\"
"
<<
"style=
\"
fill:none
\"
"
<<
"/>"
<<
std
::
endl
;
}
void
SvgPad
::
contour_point
(
double
x
,
double
y
)
{
contour_point
(
scalex
(
x
),
scaley
(
y
)
)
;
}
void
SvgPad
::
line
(
int
x1
,
int
y1
,
int
x2
,
int
y2
)
{
file_
<<
"<line "
<<
"x1=
\"
"
<<
x1
<<
"
\"
y1=
\"
"
<<
y1
<<
"
\"
"
<<
"x2=
\"
"
<<
x2
<<
"
\"
y2=
\"
"
<<
y2
<<
"
\"
"
<<
"stroke=
\"
rgb("
<<
stroke_
[
0
]
<<
", "
<<
stroke_
[
1
]
<<
", "
<<
stroke_
[
2
]
<<
")
\"
"
<<
"stroke-width=
\"
2
\"
"
<<
"/>"
<<
std
::
endl
;
}
void
SvgPad
::
line
(
double
x1
,
double
y1
,
double
x2
,
double
y2
)
{
line
(
scalex
(
x1
),
scaley
(
y1
),
scalex
(
x2
),
scaley
(
y2
)
)
;
}
void
SvgPad
::
triangle
(
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
x3
,
int
y3
)
{
file_
<<
"<polygon "
<<
"points=
\"
"
<<
x1
<<
","
<<
y1
<<
" "
<<
x2
<<
","
<<
y2
<<
" "
<<
x3
<<
","
<<
y3
<<
"
\"
"
<<
"fill=
\"
rgb("
<<
fill_
[
0
]
<<
", "
<<
fill_
[
1
]
<<
", "
<<
fill_
[
2
]
<<
")
\"
"
<<
"stroke=
\"
rgb("
<<
stroke_
[
0
]
<<
", "
<<
stroke_
[
1
]
<<
", "
<<
stroke_
[
2
]
<<
")
\"
"
<<
"stroke-width=
\"
2
\"
"
<<
"/>"
<<
std
::
endl
;
}
void
SvgPad
::
triangle
(
double
x1
,
double
y1
,
double
x2
,
double
y2
,
double
x3
,
double
y3
)
{
triangle
(
scalex
(
x1
),
scaley
(
y1
),
scalex
(
x2
),
scaley
(
y2
),
scalex
(
x3
),
scaley
(
y3
)
)
;
}
void
SvgPad
::
polygon
(
const
int
*
vertices
,
unsigned
int
size
)
{
file_
<<
"<polygon "
<<
"points=
\"
"
;
for
(
unsigned
int
i
=
0
;
i
<
size
;
++
i
)
{
file_
<<
vertices
[
2
*
i
]
<<
","
<<
vertices
[
2
*
i
+
1
]
<<
" "
;
}
set_fill_stroke
()
;
file_
<<
"/>"
<<
std
::
endl
;
}
void
SvgPad
::
polygon
(
const
double
*
vertices
,
unsigned
int
size
)
{
file_
<<
"<polygon "
<<
"points=
\"
"
;
for
(
unsigned
int
i
=
0
;
i
<
size
;
++
i
)
{
file_
<<
scalex
(
vertices
[
2
*
i
])
<<
","
<<
scaley
(
vertices
[
2
*
i
+
1
])
<<
" "
;
}
set_fill_stroke
()
;
file_
<<
"/>"
<<
std
::
endl
;
}
void
SvgPad
::
box
(
int
minx
,
int
miny
,
int
maxx
,
int
maxy
)
{
file_
<<
"<polygon "
<<
"points=
\"
"
<<
minx
<<
","
<<
miny
<<
" "
<<
maxx
<<
","
<<
miny
<<
" "
<<
maxx
<<
","
<<
maxy
<<
" "
<<
minx
<<
","
<<
maxy
<<
"
\"
"
<<
"fill=
\"
rgb("
<<
fill_
[
0
]
<<
", "
<<
fill_
[
1
]
<<
", "
<<
fill_
[
2
]
<<
")
\"
"
<<
"stroke=
\"
rgb("
<<
stroke_
[
0
]
<<
", "
<<
stroke_
[
1
]
<<
", "
<<
stroke_
[
2
]
<<
")
\"
"
<<
"stroke-width=
\"
2
\"
"
<<
"/>"
<<
std
::
endl
;
}
void
SvgPad
::
box
(
double
minx
,
double
miny
,
double
maxx
,
double
maxy
)
{
box
(
scalex
(
minx
),
scaley
(
miny
),
scalex
(
maxx
),
scaley
(
maxy
)
)
;
}
int
SvgPad
::
scalex
(
double
x
)
{
int
margin
=
width_
*
5
/
100
;
return
(
int
)
margin
+
x
*
(
width_
-
2
*
margin
)
;
}
int
SvgPad
::
scaley
(
double
x
)
{
int
margin
=
height_
*
5
/
100
;
return
(
int
)
margin
+
(
1
-
x
)
*
(
height_
-
2
*
margin
)
;
}
int
SvgPad
::
scale_byte
(
double
v
)
{
return
std
::
min
((
int
)
(
v
*
256
),
255
)
;
}
void
SvgPad
::
fill
(
int
r
,
int
g
,
int
b
)
{
fill_
[
0
]
=
r
;
fill_
[
1
]
=
g
;
fill_
[
2
]
=
b
;
}
void
SvgPad
::
fill
(
const
int
color
[
3
])
{
std
::
copy
(
color
,
color
+
3
,
fill_
)
;
}
void
SvgPad
::
fill
(
double
r
,
double
g
,
double
b
)
{
fill
(
scale_byte
(
r
),
scale_byte
(
g
),
scale_byte
(
b
))
;
}
void
SvgPad
::
fill
(
const
double
color
[
3
])
{
fill
(
scale_byte
(
color
[
0
]),
scale_byte
(
color
[
1
]),
scale_byte
(
color
[
2
]))
;
}
void
SvgPad
::
toggle_fill
()
{
use_fill_
=
!
use_fill_
;
}
void
SvgPad
::
stroke
(
int
r
,
int
g
,
int
b
)
{
stroke_
[
0
]
=
r
;
stroke_
[
1
]
=
g
;
stroke_
[
2
]
=
b
;
}
void
SvgPad
::
stroke
(
const
int
color
[
3
])
{
std
::
copy
(
color
,
color
+
3
,
stroke_
)
;
}
void
SvgPad
::
stroke
(
double
r
,
double
g
,
double
b
)
{
stroke
(
scale_byte
(
r
),
scale_byte
(
g
),
scale_byte
(
b
))
;
}
void
SvgPad
::
stroke
(
const
double
color
[
3
])
{
stroke
(
scale_byte
(
color
[
0
]),
scale_byte
(
color
[
1
]),
scale_byte
(
color
[
2
]))
;
}
void
SvgPad
::
toggle_stroke
()
{
use_stroke_
=
!
use_stroke_
;
}
void
SvgPad
::
set_fill_stroke
()
{
file_
<<
"fill=
\"
"
;
if
(
use_fill_
)
{
file_
<<
"rgb("
<<
fill_
[
0
]
<<
", "
<<
fill_
[
1
]
<<
", "
<<
fill_
[
2
]
<<
")"
;
}
else
{
file_
<<
"none"
;
}
file_
<<
"
\"
stroke=
\"
"
;
if
(
use_stroke_
)
{
file_
<<
"rgb("
<<
stroke_
[
0
]
<<
", "
<<
stroke_
[
1
]
<<
", "
<<
stroke_
[
2
]
<<
")"
;
}
else
{
file_
<<
"none"
;
}
file_
<<
"
\"
"
;
}
void
SvgPad
::
open
()
{
file_
<<
"<svg height=
\"
"
<<
height_
<<
"
\"
width=
\"
"
<<
width_
<<
"
\"
>"
<<
std
::
endl
;
}
void
SvgPad
::
close
()
{
file_
<<
"</svg>"
<<
std
::
endl
;
}
This diff is collapsed.
Click to expand it.
Code/svg.hpp
0 → 100644
+
99
−
0
View file @
f5511ce2
// @licstart revoropt
// This file is part of Revoropt, a library for the computation and
// optimization of restricted Voronoi diagrams.
//
// Copyright (C) 2013 Vincent Nivoliers <vincent.nivoliers@univ-lyon1.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// @licend revoropt
#ifndef SVGPAD_HPP
#define SVGPAD_HPP
#include
<iostream>
#include
<fstream>
/** tools to generate svg images **/
class
SvgPad
{
public
:
/* Construction, destruction */
SvgPad
(
std
::
ofstream
&
file
,
int
width
,
int
height
)
:
file_
(
file
),
width_
(
width
),
height_
(
height
),
fill_
(),
stroke_
(),
use_fill_
(
true
),
use_stroke_
(
true
)
{}
/* Opening, closing */
void
open
()
;
void
close
()
;
/* Drawing */
/* integer parameters should be in [0,width]x[0,height] */
/* double parameters should be in [0,1]x[0,1] */
void
solid_point
(
int
x
,
int
y
)
;
void
solid_point
(
double
x
,
double
y
)
;
void
contour_point
(
int
x
,
int
y
)
;
void
contour_point
(
double
x
,
double
y
)
;
void
line
(
int
x1
,
int
y1
,
int
x2
,
int
y2
)
;
void
line
(
double
x1
,
double
y1
,
double
x2
,
double
y2
)
;
void
triangle
(
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
x3
,
int
y3
)
;
void
triangle
(
double
x1
,
double
y1
,
double
x2
,
double
y2
,
double
x3
,
double
y3
)
;
void
polygon
(
const
int
*
vertices
,
unsigned
int
size
)
;
void
polygon
(
const
double
*
vertices
,
unsigned
int
size
)
;
void
box
(
int
minx
,
int
miny
,
int
maxx
,
int
maxy
)
;
void
box
(
double
minx
,
double
miny
,
double
maxx
,
double
maxy
)
;
/* Scaling from [0,1] to the dimension with a 5% margin */
int
scalex
(
double
x
)
;
int
scaley
(
double
y
)
;
int
scale_byte
(
double
v
)
;
/* Colors */
void
fill
(
int
r
,
int
g
,
int
b
)
;
void
fill
(
const
int
color
[
3
])
;
void
fill
(
double
r
,
double
g
,
double
b
)
;
void
fill
(
const
double
color
[
3
])
;
void
toggle_fill
()
;
void
stroke
(
int
r
,
int
g
,
int
b
)
;
void
stroke
(
const
int
color
[
3
])
;
void
stroke
(
double
r
,
double
g
,
double
b
)
;
void
stroke
(
const
double
color
[
3
])
;
void
toggle_stroke
()
;
private
:
/* Output file */
std
::
ofstream
&
file_
;
/* Dimensions */
int
width_
;
int
height_
;
/* Colors */
int
fill_
[
3
]
;
int
stroke_
[
3
]
;
bool
use_fill_
;
bool
use_stroke_
;
void
set_fill_stroke
()
;
}
;
#endif
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
sign in
to comment