Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
2a3ae917
Commit
2a3ae917
authored
Jan 09, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
after QList -> QVector, circ survey 4 times faster
parent
19b98503
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
202660 additions
and
99 deletions
+202660
-99
perfCircSurvey.plan
Paths/perfCircSurvey.plan
+202542
-0
Circle.cc
src/Wima/Circle.cc
+10
-10
Circle.h
src/Wima/Circle.h
+4
-4
CircularSurveyComplexItem.cc
src/Wima/CircularSurveyComplexItem.cc
+20
-23
GeoUtilities.cc
src/Wima/GeoUtilities.cc
+9
-0
GeoUtilities.h
src/Wima/GeoUtilities.h
+5
-3
PlanimetryCalculus.cc
src/Wima/PlanimetryCalculus.cc
+35
-35
PlanimetryCalculus.h
src/Wima/PlanimetryCalculus.h
+18
-18
PolygonCalculus.cc
src/Wima/PolygonCalculus.cc
+15
-6
PolygonCalculus.h
src/Wima/PolygonCalculus.h
+2
-0
No files found.
Paths/perfCircSurvey.plan
0 → 100644
View file @
2a3ae917
This diff is collapsed.
Click to expand it.
src/Wima/Circle.cc
View file @
2a3ae917
...
...
@@ -88,38 +88,38 @@ QPointF Circle::origin() const
/*!
* \fn Q
List
<QPointF> Circle::approximate(int numberOfCorners)
* \fn Q
Vector
<QPointF> Circle::approximate(int numberOfCorners)
* Returns a polygon with \a numberOfCorners corners which approximates the circle.
*
* \sa QPointF
*/
Q
List
<
QPointF
>
Circle
::
approximate
(
int
numberOfCorners
)
const
Q
Vector
<
QPointF
>
Circle
::
approximate
(
int
numberOfCorners
)
const
{
if
(
numberOfCorners
<
3
)
return
Q
List
<
QPointF
>
();
return
Q
Vector
<
QPointF
>
();
return
approximateSektor
(
numberOfCorners
+
1
,
0
,
2
*
M_PI
);
}
Q
List
<
QPointF
>
Circle
::
approximate
(
double
angleDiscretisation
)
const
Q
Vector
<
QPointF
>
Circle
::
approximate
(
double
angleDiscretisation
)
const
{
return
approximateSektor
(
angleDiscretisation
,
0
,
2
*
M_PI
);
}
Q
List
<
QPointF
>
Circle
::
approximateSektor
(
int
numberOfCorners
,
double
alpha1
,
double
alpha2
)
const
Q
Vector
<
QPointF
>
Circle
::
approximateSektor
(
int
numberOfCorners
,
double
alpha1
,
double
alpha2
)
const
{
if
(
numberOfCorners
<
2
)
{
qWarning
(
"numberOfCorners < 2"
);
return
Q
List
<
QPointF
>
();
return
Q
Vector
<
QPointF
>
();
}
return
approximateSektor
(
PlanimetryCalculus
::
truncateAngle
(
alpha2
-
alpha1
)
/
double
(
numberOfCorners
-
1
),
alpha1
,
alpha2
);
}
Q
List
<
QPointF
>
Circle
::
approximateSektor
(
double
angleDiscretisation
,
double
alpha1
,
double
alpha2
)
const
Q
Vector
<
QPointF
>
Circle
::
approximateSektor
(
double
angleDiscretisation
,
double
alpha1
,
double
alpha2
)
const
{
using
namespace
PlanimetryCalculus
;
// check if input is valid
if
(
qFuzzyCompare
(
alpha1
,
alpha2
)
)
return
Q
List
<
QPointF
>
();
return
Q
Vector
<
QPointF
>
();
alpha1
=
truncateAngle
(
alpha1
);
alpha2
=
truncateAngle
(
alpha2
);
...
...
@@ -130,10 +130,10 @@ QList<QPointF> Circle::approximateSektor(double angleDiscretisation, double alph
// check if input is valid
if
(
qFuzzyIsNull
(
angleDiscretisation
))
return
Q
List
<
QPointF
>
();
return
Q
Vector
<
QPointF
>
();
Q
List
<
QPointF
>
sector
;
Q
Vector
<
QPointF
>
sector
;
double
currentAngle
=
alpha1
;
// how many nodes?
int
j
=
floor
(
fabs
(
deltaAlpha
/
angleDiscretisation
));
...
...
src/Wima/Circle.h
View file @
2a3ae917
...
...
@@ -27,10 +27,10 @@ public:
QPointF
origin
()
const
;
// Member methodes
Q
List
<
QPointF
>
approximate
(
int
numberOfCorners
)
const
;
Q
List
<
QPointF
>
approximate
(
double
angleDiscretisation
)
const
;
Q
List
<
QPointF
>
approximateSektor
(
int
numberOfCorners
,
double
alpha1
,
double
alpha2
)
const
;
Q
List
<
QPointF
>
approximateSektor
(
double
angleDiscretisation
,
double
alpha1
,
double
alpha2
)
const
;
Q
Vector
<
QPointF
>
approximate
(
int
numberOfCorners
)
const
;
Q
Vector
<
QPointF
>
approximate
(
double
angleDiscretisation
)
const
;
Q
Vector
<
QPointF
>
approximateSektor
(
int
numberOfCorners
,
double
alpha1
,
double
alpha2
)
const
;
Q
Vector
<
QPointF
>
approximateSektor
(
double
angleDiscretisation
,
double
alpha1
,
double
alpha2
)
const
;
void
toCoordinate
(
QPointF
&
toCoordinate
,
double
alpha
)
const
;
QPointF
toCoordinate
(
double
alpha
)
const
;
bool
isNull
()
const
;
...
...
src/Wima/CircularSurveyComplexItem.cc
View file @
2a3ae917
...
...
@@ -462,14 +462,14 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// generate transects
Q
List
<
QList
<
QPointF
>>
transectPath
;
Q
Vector
<
QVector
<
QPointF
>>
transectPath
;
double
r
=
r_min
;
while
(
r
<
r_max
)
{
Circle
circle
(
r
,
origin
);
Q
List
<
QPointFList
>
intersectPoints
;
Q
List
<
IntersectType
>
typeList
;
Q
List
<
QPair
<
int
,
int
>>
neighbourList
;
Q
Vector
<
QPointFVector
>
intersectPoints
;
Q
Vector
<
IntersectType
>
typeList
;
Q
Vector
<
QPair
<
int
,
int
>>
neighbourList
;
if
(
intersects
(
circle
,
surveyPolygon
,
intersectPoints
,
neighbourList
,
typeList
))
{
// intersection Points between circle and polygon, entering polygon
...
...
@@ -480,7 +480,7 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
QPointFList
exitPoints
;
// determine entryPoints and exit Points
for
(
int
j
=
0
;
j
<
intersectPoints
.
size
();
j
++
)
{
Q
List
<
QPointF
>
intersects
=
intersectPoints
[
j
];
// one pt = tangent, two pt = sekant
Q
Vector
<
QPointF
>
intersects
=
intersectPoints
[
j
];
// one pt = tangent, two pt = sekant
QPointF
p1
=
surveyPolygon
[
neighbourList
[
j
].
first
];
QPointF
p2
=
surveyPolygon
[
neighbourList
[
j
].
second
];
...
...
@@ -544,7 +544,7 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// qDebug() << "dAlpha" << dAlpha;
// qDebug() << "numNodes" << numNodes;
Q
List
<
QPointF
>
sectorPath
=
circle
.
approximateSektor
(
numNodes
,
alpha1
,
alpha2
);
Q
Vector
<
QPointF
>
sectorPath
=
circle
.
approximateSektor
(
numNodes
,
alpha1
,
alpha2
);
// use shortestPath() here if necessary, could be a problem if dr >>
if
(
sectorPath
.
size
()
>
0
)
transectPath
.
append
(
sectorPath
);
...
...
@@ -552,7 +552,7 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
}
else
if
(
originInside
)
{
// circle fully inside polygon
int
numNodes
=
int
(
ceil
(
2
*
M_PI
/
dalpha
))
+
1
;
Q
List
<
QPointF
>
sectorPath
=
circle
.
approximateSektor
(
numNodes
,
0
,
2
*
M_PI
);
Q
Vector
<
QPointF
>
sectorPath
=
circle
.
approximateSektor
(
numNodes
,
0
,
2
*
M_PI
);
// use shortestPath() here if necessary, could be a problem if dr >>
transectPath
.
append
(
sectorPath
);
}
...
...
@@ -579,10 +579,10 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// optimize path to snake or zig-zag pattern
bool
isSnakePattern
=
_isSnakePath
.
rawValue
().
toBool
();
Q
List
<
QPointF
>
currentSection
=
transectPath
.
takeFirst
();
Q
Vector
<
QPointF
>
currentSection
=
transectPath
.
takeFirst
();
if
(
currentSection
.
isEmpty
()
)
return
;
Q
List
<
QList
<
QPointF
>
>
optiPath
;
// optimized path
Q
Vector
<
QPointF
>
optiPath
;
// optimized path
while
(
!
transectPath
.
empty
()
)
{
optiPath
.
append
(
currentSection
);
QPointF
endVertex
=
currentSection
.
last
();
...
...
@@ -616,24 +616,21 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// convert to CoordInfo_t
for
(
QList
<
QPointF
>
&
transect
:
optiPath
)
{
// for ( const QList<QPointF> &transect : fullPath) {
if
(
_reverse
.
rawValue
().
toBool
())
PolygonCalculus
::
reversePath
(
transect
);
QList
<
QGeoCoordinate
>
geoPath
=
toGeo
(
transect
,
_referencePoint
);
QList
<
CoordInfo_t
>
transectList
;
for
(
const
QGeoCoordinate
&
coordinate
:
geoPath
)
{
CoordInfo_t
coordinfo
=
{
coordinate
,
CoordTypeInterior
};
transectList
.
append
(
coordinfo
);
}
_transects
.
append
(
transectList
);
if
(
_reverse
.
rawValue
().
toBool
())
PolygonCalculus
::
reversePath
(
optiPath
);
QList
<
QGeoCoordinate
>
geoPath
=
toGeo
(
optiPath
,
_referencePoint
);
QList
<
CoordInfo_t
>
transectList
;
for
(
const
QGeoCoordinate
&
coordinate
:
geoPath
)
{
CoordInfo_t
coordinfo
=
{
coordinate
,
CoordTypeInterior
};
transectList
.
append
(
coordinfo
);
}
_transects
.
append
(
transectList
);
qDebug
()
<<
"CircularSurveyComplexItem::_rebuildTransectsPhase1(): calls: "
<<
_updateCounter
;
auto
delta
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
std
::
chrono
::
high_resolution_clock
::
now
()
-
startTime
).
count
();
qDebug
()
<<
"CircularSurveyComplexItem::_rebuildTransectsPhase1(): time: "
<<
delta
;
qDebug
()
<<
sizeof
(
QPointF
);
qDebug
()
<<
"CircularSurveyComplexItem::_rebuildTransectsPhase1(): time: "
<<
delta
<<
" ms"
;
//
qDebug() << sizeof(QPointF);
}
...
...
src/Wima/GeoUtilities.cc
View file @
2a3ae917
...
...
@@ -101,5 +101,14 @@ namespace GeoUtilities {
return
coordinates
;
}
QGeoList
toGeo
(
const
QPointFVector
&
points
,
const
QGeoCoordinate
&
origin
)
{
QGeoList
coordinates
;
for
(
auto
point
:
points
)
coordinates
.
append
(
toGeo
(
point
,
origin
));
return
coordinates
;
}
}
src/Wima/GeoUtilities.h
View file @
2a3ae917
...
...
@@ -11,9 +11,10 @@
namespace
GeoUtilities
{
typedef
QList
<
QVector3D
>
QVector3DList
;
typedef
QList
<
QPointF
>
QPointFList
;
typedef
QList
<
QGeoCoordinate
>
QGeoList
;
typedef
QList
<
QVector3D
>
QVector3DList
;
typedef
QList
<
QPointF
>
QPointFList
;
typedef
QVector
<
QPointF
>
QPointFVector
;
typedef
QList
<
QGeoCoordinate
>
QGeoList
;
const
double
earthRadius
=
6378137
;
// meter
...
...
@@ -21,6 +22,7 @@ namespace GeoUtilities {
QGeoList
toGeo
(
const
QVector3DList
&
points
,
const
QGeoCoordinate
&
origin
);
QGeoCoordinate
toGeo
(
const
QPointF
&
point
,
const
QGeoCoordinate
&
origin
);
QGeoList
toGeo
(
const
QPointFList
&
points
,
const
QGeoCoordinate
&
origin
);
QGeoList
toGeo
(
const
QPointFVector
&
points
,
const
QGeoCoordinate
&
origin
);
QVector3D
toCartesian
(
const
QGeoCoordinate
&
coordinate
,
const
QGeoCoordinate
&
origin
);
QVector3DList
toCartesian
(
const
QGeoList
&
coordinates
,
const
QGeoCoordinate
&
origin
);
QPointF
toCartesian2D
(
const
QGeoCoordinate
&
point
,
const
QGeoCoordinate
&
origin
);
...
...
src/Wima/PlanimetryCalculus.cc
View file @
2a3ae917
...
...
@@ -12,7 +12,7 @@ namespace PlanimetryCalculus {
\sa QPointF, Circle
*/
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
List
&
intersectionPoints
,
IntersectType
&
type
,
bool
calcInstersect
)
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionPoints
,
IntersectType
&
type
,
bool
calcInstersect
)
{
if
(
!
circle
.
isNull
()
&&
!
line
.
isNull
())
{
QPointF
translationVector
=
line
.
p1
();
...
...
@@ -87,7 +87,7 @@ namespace PlanimetryCalculus {
\sa Circle
*/
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
List
&
intersectionPoints
,
IntersectType
type
,
bool
calcIntersection
)
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
Vector
&
intersectionPoints
,
IntersectType
type
,
bool
calcIntersection
)
{
if
(
!
circle1
.
isNull
()
&&
!
circle2
.
isNull
())
{
double
r1
=
circle1
.
radius
();
...
...
@@ -180,7 +180,7 @@ namespace PlanimetryCalculus {
}
}
void
rotateReference
(
QPointF
List
&
points
,
double
alpha
)
void
rotateReference
(
QPointF
Vector
&
points
,
double
alpha
)
{
for
(
int
i
=
0
;
i
<
points
.
size
();
i
++
)
{
rotateReference
(
points
[
i
],
alpha
);
...
...
@@ -196,7 +196,7 @@ namespace PlanimetryCalculus {
rotateReference
(
point
,
alpha
/
180
*
M_PI
);
}
void
rotateReferenceDegree
(
QPointF
List
&
points
,
double
alpha
)
void
rotateReferenceDegree
(
QPointF
Vector
&
points
,
double
alpha
)
{
for
(
int
i
=
0
;
i
<
points
.
size
();
i
++
)
{
rotateReferenceDegree
(
points
[
i
],
alpha
);
...
...
@@ -212,12 +212,12 @@ namespace PlanimetryCalculus {
*/
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
)
{
QPointF
List
dummyList
;
QPointF
Vector
dummyList
;
IntersectType
type
=
NoIntersection
;
return
intersects
(
circle
,
line
,
dummyList
,
type
,
false
/* calculate intersection points*/
);
}
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
List
&
intersectionPoints
)
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionPoints
)
{
IntersectType
type
=
NoIntersection
;
return
intersects
(
circle
,
line
,
intersectionPoints
,
type
,
true
/* calculate intersection points*/
);
...
...
@@ -396,15 +396,15 @@ angle
* \a neighbourList has entries of type \c {QPair<int, int>}, where \c{pair.first} would contain 1 and \c{pair.second} would contain 2, when
* relating to the above example.
*
* Returns the \c IntersectionType of each intersection point within a Q
List
.
* Returns the \c IntersectionType of each intersection point within a Q
Vector
.
*
* \sa QPair, Q
List
* \sa QPair, Q
Vector
*/
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
,
NeighbourList
&
neighbourList
,
IntersectList
&
typeList
)
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
NeighbourVector
&
neighbourList
,
IntersectVector
&
typeList
)
{
if
(
polygon
.
size
()
>=
2
)
{
Intersect
List
intersectionTypeList
;
Intersect
Vector
intersectionTypeList
;
// Assemble a line form each tow consecutive polygon vertices and check whether it intersects with line
for
(
int
i
=
0
;
i
<
polygon
.
size
();
i
++
)
{
...
...
@@ -442,12 +442,12 @@ angle
* \overload IntersectType intersects(const QPolygonF &polygon, const QLineF &line)
* Returns \c true if any intersection between \a polygon and \a line exists, \c false else.
*
* \sa QPair, Q
List
* \sa QPair, Q
Vector
*/
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
)
{
QPointF
List
dummyGeo
;
Q
List
<
QPair
<
int
,
int
>>
dummyNeighbour
;
QPointF
Vector
dummyGeo
;
Q
Vector
<
QPair
<
int
,
int
>>
dummyNeighbour
;
intersects
(
polygon
,
line
,
dummyGeo
,
dummyNeighbour
);
if
(
dummyGeo
.
size
()
>
0
)
...
...
@@ -468,7 +468,7 @@ angle
return
point
;
}
QPointF
List
rotateReturn
(
QPointFList
points
,
double
alpha
)
QPointF
Vector
rotateReturn
(
QPointFVector
points
,
double
alpha
)
{
rotateReference
(
points
,
alpha
);
return
points
;
...
...
@@ -488,22 +488,22 @@ angle
return
intersects
(
line1
,
line2
,
intersectionPt
,
dummyType
);
}
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
,
NeighbourList
&
neighbourList
)
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
NeighbourVector
&
neighbourList
)
{
Intersect
List
typeList
;
Intersect
Vector
typeList
;
return
intersects
(
polygon
,
line
,
intersectionList
,
neighbourList
,
typeList
);
}
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
,
IntersectList
&
typeList
)
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
IntersectVector
&
typeList
)
{
Neighbour
List
neighbourList
;
Neighbour
Vector
neighbourList
;
return
intersects
(
polygon
,
line
,
intersectionList
,
neighbourList
,
typeList
);
}
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
)
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
)
{
Neighbour
List
neighbourList
;
Intersect
List
typeList
;
Neighbour
Vector
neighbourList
;
Intersect
Vector
typeList
;
return
intersects
(
polygon
,
line
,
intersectionList
,
neighbourList
,
typeList
);
}
...
...
@@ -518,23 +518,23 @@ angle
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
)
{
IntersectType
type
=
NoIntersection
;
QPointF
List
intersectionPoints
;
QPointF
Vector
intersectionPoints
;
return
intersects
(
circle1
,
circle2
,
intersectionPoints
,
type
,
false
/*calculate intersection points*/
);
}
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
IntersectType
&
type
)
{
QPointF
List
intersectionPoints
;
QPointF
Vector
intersectionPoints
;
return
intersects
(
circle1
,
circle2
,
intersectionPoints
,
type
,
false
/*calculate intersection points*/
);
}
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
List
&
intersectionPoints
)
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
Vector
&
intersectionPoints
)
{
IntersectType
type
;
return
intersects
(
circle1
,
circle2
,
intersectionPoints
,
type
);
}
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
List
&
intersectionPoints
,
IntersectType
&
type
)
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
Vector
&
intersectionPoints
,
IntersectType
&
type
)
{
return
intersects
(
circle1
,
circle2
,
intersectionPoints
,
type
,
true
/*calculate intersection points*/
);
}
...
...
@@ -623,7 +623,7 @@ angle
return
truncateAngle
(
qAtan2
(
p1
.
y
(),
p1
.
x
()));
}
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointFList
>
&
intersectionPoints
,
NeighbourList
&
neighbourList
,
IntersectList
&
typeList
)
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointFVector
>
&
intersectionPoints
,
NeighbourVector
&
neighbourList
,
IntersectVector
&
typeList
)
{
using
namespace
PolygonCalculus
;
for
(
int
i
=
0
;
i
<
polygon
.
size
();
i
++
)
{
...
...
@@ -632,7 +632,7 @@ angle
QPointF
p2
=
polygon
[
j
];
QLineF
line
(
p1
,
p2
);
QPointF
List
lineIntersecPts
;
QPointF
Vector
lineIntersecPts
;
IntersectType
type
;
if
(
intersects
(
circle
,
line
,
lineIntersecPts
,
type
))
{
QPair
<
int
,
int
>
neigbours
;
...
...
@@ -652,27 +652,27 @@ angle
}
}
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointFList
>
&
intersectionPoints
,
NeighbourList
&
neighbourList
)
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointFVector
>
&
intersectionPoints
,
NeighbourVector
&
neighbourList
)
{
Q
List
<
IntersectType
>
types
;
Q
Vector
<
IntersectType
>
types
;
return
intersects
(
circle
,
polygon
,
intersectionPoints
,
neighbourList
,
types
);
}
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointFList
>
&
intersectionPoints
,
IntersectList
&
typeList
)
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointFVector
>
&
intersectionPoints
,
IntersectVector
&
typeList
)
{
Neighbour
List
neighbourList
;
Neighbour
Vector
neighbourList
;
return
intersects
(
circle
,
polygon
,
intersectionPoints
,
neighbourList
,
typeList
);
}
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointFList
>
&
intersectionPoints
)
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointFVector
>
&
intersectionPoints
)
{
Neighbour
List
neighbourList
;
Neighbour
Vector
neighbourList
;
return
intersects
(
circle
,
polygon
,
intersectionPoints
,
neighbourList
);
}
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
)
{
Q
List
<
QPointFList
>
intersectionPoints
;
Q
Vector
<
QPointFVector
>
intersectionPoints
;
return
intersects
(
circle
,
polygon
,
intersectionPoints
);
}
...
...
@@ -682,7 +682,7 @@ angle
return
intersects
(
line1
,
line2
,
intersectionPoint
);
}
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
List
&
intersectionPoints
,
IntersectType
&
type
)
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionPoints
,
IntersectType
&
type
)
{
return
intersects
(
circle
,
line
,
intersectionPoints
,
type
,
true
/* calculate intersection points*/
);
}
...
...
src/Wima/PlanimetryCalculus.h
View file @
2a3ae917
...
...
@@ -26,43 +26,43 @@ namespace PlanimetryCalculus {
NoIntersection
,
Error
// general
};
typedef
Q
List
<
QPair
<
int
,
int
>>
NeighbourList
;
typedef
Q
List
<
QPointF
>
QPointFList
;
typedef
Q
List
<
IntersectType
>
IntersectList
;
typedef
Q
Vector
<
QPair
<
int
,
int
>>
NeighbourVector
;
typedef
Q
Vector
<
QPointF
>
QPointFVector
;
typedef
Q
Vector
<
IntersectType
>
IntersectVector
;
void
rotateReference
(
QPointF
&
point
,
double
alpha
);
void
rotateReference
(
QPointF
List
&
points
,
double
alpha
);
void
rotateReference
(
QPointF
Vector
&
points
,
double
alpha
);
void
rotateReference
(
QLineF
&
line
,
double
alpha
);
//void rotateReference(QPolygonF &polygon, double alpha);
QPointF
rotateReturn
(
QPointF
point
,
double
alpha
);
QPointF
List
rotateReturn
(
QPointFList
points
,
double
alpha
);
QPointF
Vector
rotateReturn
(
QPointFVector
points
,
double
alpha
);
QLineF
rotateReturn
(
QLineF
line
,
double
alpha
);
//QPolygonF rotateReturn(QPolygonF &polygon, double alpha);
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
);
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
IntersectType
&
type
);
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
List
&
intersectionPoints
);
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
List
&
intersectionPoints
,
IntersectType
&
type
);
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
Vector
&
intersectionPoints
);
bool
intersects
(
const
Circle
&
circle1
,
const
Circle
&
circle2
,
QPointF
Vector
&
intersectionPoints
,
IntersectType
&
type
);
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
);
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
IntersectType
&
type
);
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
List
&
intersectionPoints
);
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
List
&
intersectionPoints
,
IntersectType
&
type
);
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionPoints
);
bool
intersects
(
const
Circle
&
circle
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionPoints
,
IntersectType
&
type
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointFList
>
&
intersectionPoints
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointFList
>
&
intersectionPoints
,
IntersectList
&
typeList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointFList
>
&
intersectionPoints
,
NeighbourList
&
neighbourList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointFList
>
&
intersectionPoints
,
NeighbourList
&
neighbourList
,
IntersectList
&
typeList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointFVector
>
&
intersectionPoints
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointFVector
>
&
intersectionPoints
,
IntersectVector
&
typeList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointFVector
>
&
intersectionPoints
,
NeighbourVector
&
neighbourList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointFVector
>
&
intersectionPoints
,
NeighbourVector
&
neighbourList
,
IntersectVector
&
typeList
);
bool
intersects
(
const
QLineF
&
line1
,
const
QLineF
&
line2
);
bool
intersects
(
const
QLineF
&
line1
,
const
QLineF
&
line2
,
QPointF
&
intersectionPt
);
bool
intersects
(
const
QLineF
&
line1
,
const
QLineF
&
line2
,
QPointF
&
intersectionPt
,
IntersectType
&
type
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
,
IntersectList
&
typeList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
,
NeighbourList
&
neighbourList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
,
NeighbourList
&
neighbourList
,
IntersectList
&
typeList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
IntersectVector
&
typeList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
NeighbourVector
&
neighbourList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
NeighbourVector
&
neighbourList
,
IntersectVector
&
typeList
);
bool
contains
(
const
QLineF
&
line
,
const
QPointF
&
point
);
bool
contains
(
const
QLineF
&
line
,
const
QPointF
&
point
,
IntersectType
&
type
);
...
...
@@ -84,7 +84,7 @@ namespace PlanimetryCalculus {
* \fntemplate <typename T> int signum(T val)
* Returns the signum of a value \a val.
*
* \sa QPair, Q
List
* \sa QPair, Q
Vector
*/
template
<
typename
T
>
int
signum
(
T
val
)
{
...
...
src/Wima/PolygonCalculus.cc
View file @
2a3ae917
...
...
@@ -32,11 +32,11 @@ namespace PolygonCalculus {
if
(
!
polygon
.
containsPoint
(
c1
,
Qt
::
FillRule
::
OddEvenFill
)
||
!
polygon
.
containsPoint
(
c2
,
Qt
::
FillRule
::
OddEvenFill
))
return
false
;
Q
List
<
QPointF
>
intersectionList
;
Q
Vector
<
QPointF
>
intersectionList
;
QLineF
line
;
line
.
setP1
(
c1
);
line
.
setP2
(
c2
);
PlanimetryCalculus
::
Intersect
List
intersectTypeList
;
PlanimetryCalculus
::
Intersect
Vector
intersectTypeList
;
bool
retValue
=
PlanimetryCalculus
::
intersects
(
polygon
,
line
,
intersectionList
,
intersectTypeList
);
if
(
retValue
)
{
...
...
@@ -191,8 +191,8 @@ namespace PolygonCalculus {
walkerPolySegment
.
setP1
(
currentVertex
);
walkerPolySegment
.
setP2
(
protoNextVertex
);
Q
List
<
QPair
<
int
,
int
>>
neighbourList
;
Q
List
<
QPointF
>
intersectionList
;
Q
Vector
<
QPair
<
int
,
int
>>
neighbourList
;
Q
Vector
<
QPointF
>
intersectionList
;
//qDebug("IntersectionList.size() on init: %i", intersectionList.size());
PlanimetryCalculus
::
intersects
(
*
crossPoly
,
walkerPolySegment
,
intersectionList
,
neighbourList
);
...
...
@@ -538,10 +538,19 @@ namespace PolygonCalculus {
for
(
auto
element
:
path
)
{
pathReversed
.
prepend
(
element
);
}
path
.
clear
();
path
.
append
(
pathReversed
);
path
=
pathReversed
;
}
void
reversePath
(
QPointFVector
&
path
)
{
QPointFVector
pathReversed
;
for
(
auto
element
:
path
)
{
pathReversed
.
prepend
(
element
);
}
path
=
pathReversed
;
}
}
// end PolygonCalculus namespace
src/Wima/PolygonCalculus.h
View file @
2a3ae917
...
...
@@ -13,6 +13,7 @@ namespace PolygonCalculus {
typedef
QList
<
QVector3D
>
QVector3DList
;
typedef
QList
<
QPointF
>
QPointFList
;
typedef
QVector
<
QPointF
>
QPointFVector
;
int
closestVertexIndex
(
const
QPolygonF
&
polygon
,
const
QPointF
&
coordinate
);
QPointF
closestVertex
(
const
QPolygonF
&
polygon
,
const
QPointF
&
coordinate
);
...
...
@@ -23,6 +24,7 @@ namespace PolygonCalculus {
bool
hasClockwiseWinding
(
const
QPolygonF
&
path
);
void
reversePath
(
QPolygonF
&
path
);
void
reversePath
(
QPointFList
&
path
);
void
reversePath
(
QPointFVector
&
path
);
void
offsetPolygon
(
QPolygonF
&
polygon
,
double
offset
);
bool
containsPath
(
QPolygonF
polygon
,
const
QPointF
&
c1
,
const
QPointF
&
c2
);
void
decomposeToConvex
(
const
QPolygonF
&
polygon
,
QList
<
QPolygonF
>
&
convexPolygons
);
...
...
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