Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
268d9e66
Commit
268d9e66
authored
Feb 20, 2026
by
Luna Riegel
Browse files
Refactor: Change intersection method
parent
5b2b2c74
Changes
2
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/checks/topology/FeatureCollisionCheck.java
View file @
268d9e66
...
...
@@ -168,7 +168,8 @@ public class FeatureCollisionCheck extends Check{
}
private
List
<
Pair
<
Polygon
,
Polygon
>>
getCollisionPairs
(
Geometry
subjectGeom
,
Geometry
candidateGeom
){
List
<
PolygonIntersection
>
intersections
=
getPolygonIntersections
(
subjectGeom
,
candidateGeom
);
List
<
PolygonIntersection
>
intersections
=
SelfIntersectionUtil
.
calculateGeometryIntersections
(
subjectGeom
,
candidateGeom
,
epsilon
);
return
intersections
.
stream
()
.
filter
(
polySect
->
polySect
.
getType
()
!=
PolygonIntersection
.
IntersectionType
.
NONE
)
.
map
(
polySect
->
new
Pair
<>(
polySect
.
getP1
(),
polySect
.
getP2
()))
...
...
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/checks/util/SelfIntersectionUtil.java
View file @
268d9e66
...
...
@@ -84,7 +84,37 @@ public class SelfIntersectionUtil {
private
SelfIntersectionUtil
()
{
}
public
static
List
<
PolygonIntersection
>
calculateGeometryIntersections
(
Geometry
subject
,
Geometry
candidate
,
double
delta
){
List
<
TesselatedPolygon
>
tesselatedSubjectPolygons
=
tessellateGeometry
(
subject
,
delta
);
List
<
TesselatedPolygon
>
tesselatedCandidatePolygons
=
tessellateGeometry
(
candidate
,
delta
);
List
<
PolygonIntersection
>
intersections
=
new
ArrayList
<>();
for
(
TesselatedPolygon
sPoly
:
tesselatedSubjectPolygons
)
{
for
(
TesselatedPolygon
cPoly
:
tesselatedCandidatePolygons
)
{
GeometrySelfIntersection
intersection
=
doPolygonsIntersect
(
sPoly
,
cPoly
,
delta
);
if
(
intersection
!=
null
)
{
intersections
.
add
(
PolygonIntersection
.
triangles
(
intersection
.
t1
(),
intersection
.
t2
()));
}
}
}
return
intersections
;
}
private
static
List
<
TesselatedPolygon
>
tessellateGeometry
(
Geometry
geom
,
double
delta
){
List
<
TesselatedPolygon
>
tesselatedPolygons
=
new
ArrayList
<>();
for
(
Polygon
p
:
geom
.
getPolygons
())
{
TesselatedPolygon
tessPolygon
=
EarcutTesselator
.
tesselatePolygon
(
p
);
for
(
Iterator
<
Triangle3d
>
iterator
=
tessPolygon
.
getTriangles
().
iterator
();
iterator
.
hasNext
();)
{
Triangle3d
t
=
iterator
.
next
();
if
(!
t
.
hasMinExtent
(
delta
))
{
iterator
.
remove
();
}
}
tesselatedPolygons
.
add
(
tessPolygon
);
}
return
tesselatedPolygons
;
}
public
static
List
<
PolygonIntersection
>
calculateSolidSelfIntersection
(
Geometry
g
,
double
delta
)
{
List
<
TesselatedPolygon
>
tesselatedPolygons
=
new
ArrayList
<>();
for
(
Polygon
p
:
g
.
getPolygons
())
{
...
...
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