Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
2a3ae917
Commit
2a3ae917
authored
Jan 09, 2020
by
Valentin Platzgummer
Browse files
after QList -> QVector, circ survey 4 times faster
parent
19b98503
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
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
<
QPointF
List
>
intersectPoints
;
Q
List
<
IntersectType
>
typeList
;
Q
List
<
QPair
<
int
,
int
>>
neighbourList
;
Q
Vector
<
QPointF
Vector
>
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
,
Neighbour
List
&
neighbourList
,
Intersect
List
&
typeList
)
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
Neighbour
Vector
&
neighbourList
,
Intersect
Vector
&
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
(
QPointF
List
points
,
double
alpha
)
QPointF
Vector
rotateReturn
(
QPointF
Vector
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
,
Neighbour
List
&
neighbourList
)
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
Neighbour
Vector
&
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
,
Intersect
List
&
typeList
)
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
Intersect
Vector
&
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
<
QPointF
List
>
&
intersectionPoints
,
Neighbour
List
&
neighbourList
,
Intersect
List
&
typeList
)
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointF
Vector
>
&
intersectionPoints
,
Neighbour
Vector
&
neighbourList
,
Intersect
Vector
&
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
<
QPointF
List
>
&
intersectionPoints
,
Neighbour
List
&
neighbourList
)
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointF
Vector
>
&
intersectionPoints
,
Neighbour
Vector
&
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
<
QPointF
List
>
&
intersectionPoints
,
Intersect
List
&
typeList
)
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointF
Vector
>
&
intersectionPoints
,
Intersect
Vector
&
typeList
)
{
Neighbour
List
neighbourList
;
Neighbour
Vector
neighbourList
;
return
intersects
(
circle
,
polygon
,
intersectionPoints
,
neighbourList
,
typeList
);
}
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointF
List
>
&
intersectionPoints
)
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointF
Vector
>
&
intersectionPoints
)
{
Neighbour
List
neighbourList
;
Neighbour
Vector
neighbourList
;
return
intersects
(
circle
,
polygon
,
intersectionPoints
,
neighbourList
);
}
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
)
{
Q
List
<
QPointF
List
>
intersectionPoints
;
Q
Vector
<
QPointF
Vector
>
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
>>
Neighbour
List
;
typedef
Q
List
<
QPointF
>
QPointF
List
;
typedef
Q
List
<
IntersectType
>
Intersect
List
;
typedef
Q
Vector
<
QPair
<
int
,
int
>>
Neighbour
Vector
;
typedef
Q
Vector
<
QPointF
>
QPointF
Vector
;
typedef
Q
Vector
<
IntersectType
>
Intersect
Vector
;
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
(
QPointF
List
points
,
double
alpha
);
QPointF
Vector
rotateReturn
(
QPointF
Vector
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
<
QPointF
List
>
&
intersectionPoints
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointF
List
>
&
intersectionPoints
,
Intersect
List
&
typeList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointF
List
>
&
intersectionPoints
,
Neighbour
List
&
neighbourList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
List
<
QPointF
List
>
&
intersectionPoints
,
Neighbour
List
&
neighbourList
,
Intersect
List
&
typeList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointF
Vector
>
&
intersectionPoints
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointF
Vector
>
&
intersectionPoints
,
Intersect
Vector
&
typeList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointF
Vector
>
&
intersectionPoints
,
Neighbour
Vector
&
neighbourList
);
bool
intersects
(
const
Circle
&
circle
,
const
QPolygonF
&
polygon
,
Q
Vector
<
QPointF
Vector
>
&
intersectionPoints
,
Neighbour
Vector
&
neighbourList
,
Intersect
Vector
&
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
,
Intersect
List
&
typeList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
,
Neighbour
List
&
neighbourList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
List
&
intersectionList
,
Neighbour
List
&
neighbourList
,
Intersect
List
&
typeList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
Intersect
Vector
&
typeList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
Neighbour
Vector
&
neighbourList
);
bool
intersects
(
const
QPolygonF
&
polygon
,
const
QLineF
&
line
,
QPointF
Vector
&
intersectionList
,
Neighbour
Vector
&
neighbourList
,
Intersect
Vector
&
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
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment