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
1d9c7810
Commit
1d9c7810
authored
Aug 03, 2026
by
Numanoglu
Browse files
Add AABB support for buildings
parent
d5a4fafe
Pipeline
#12439
passed with stage
in 2 minutes and 11 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/aabb/AABB.java
View file @
1d9c7810
...
...
@@ -4,6 +4,9 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Objects
;
import
de.hft.stuttgart.citydoctor2.datastructure.Building
;
import
de.hft.stuttgart.citydoctor2.datastructure.BuildingPart
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
...
...
@@ -31,7 +34,26 @@ public class AABB {
return
null
;
return
of
(
ring
);
}
//----------------------------------------------
//WIP
//----------------------------------------------
public
static
AABB
of
(
Building
building
)
{
return
of
((
CityObject
)
building
);
}
public
static
AABB
of
(
BuildingPart
buildingPart
)
{
return
of
((
CityObject
)
buildingPart
);
}
public
static
AABB
of
(
CityObject
cityObject
)
{
Objects
.
requireNonNull
(
cityObject
,
"cityObject"
);
AabbExtentVisitor
visitor
=
new
AabbExtentVisitor
();
cityObject
.
accept
(
visitor
);
return
visitor
.
toAabb
();
}
//----------------------------------------------
public
static
AABB
ofPoints
(
List
<?
extends
Vector3d
>
points
)
{
double
minX
=
Double
.
POSITIVE_INFINITY
,
minY
=
Double
.
POSITIVE_INFINITY
,
minZ
=
Double
.
POSITIVE_INFINITY
;
double
maxX
=
Double
.
NEGATIVE_INFINITY
,
maxY
=
Double
.
NEGATIVE_INFINITY
,
maxZ
=
Double
.
NEGATIVE_INFINITY
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/aabb/AabbExtentVisitor.java
0 → 100644
View file @
1d9c7810
package
de.hft.stuttgart.citydoctor2.datastructure.aabb
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
/**
* Collects coordinate extrema for the AABB infrastructure while walking a
* CityDoctor object tree.
*
* adapted from older boundingbox infraustruktur
*/
final
class
AabbExtentVisitor
extends
CheckableUtilsVisitor
{
private
double
minX
=
Double
.
POSITIVE_INFINITY
;
private
double
minY
=
Double
.
POSITIVE_INFINITY
;
private
double
minZ
=
Double
.
POSITIVE_INFINITY
;
private
double
maxX
=
Double
.
NEGATIVE_INFINITY
;
private
double
maxY
=
Double
.
NEGATIVE_INFINITY
;
private
double
maxZ
=
Double
.
NEGATIVE_INFINITY
;
@Override
public
void
check
(
CityObject
cityObject
)
{
for
(
Geometry
geometry
:
cityObject
.
getGeometries
())
{
if
(
geometry
.
getVertices
()
==
null
)
{
geometry
.
updateVertices
();
}
for
(
Vertex
vertex
:
geometry
.
getVertices
())
{
include
(
vertex
);
}
}
}
AABB
toAabb
()
{
return
new
AABB
(
minX
,
minY
,
minZ
,
maxX
,
maxY
,
maxZ
);
}
private
void
include
(
Vertex
vertex
)
{
minX
=
Math
.
min
(
minX
,
vertex
.
getX
());
minY
=
Math
.
min
(
minY
,
vertex
.
getY
());
minZ
=
Math
.
min
(
minZ
,
vertex
.
getZ
());
maxX
=
Math
.
max
(
maxX
,
vertex
.
getX
());
maxY
=
Math
.
max
(
maxY
,
vertex
.
getY
());
maxZ
=
Math
.
max
(
maxZ
,
vertex
.
getZ
());
}
}
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/datastructure/aabb/AABBTest.java
View file @
1d9c7810
...
...
@@ -6,9 +6,15 @@ import java.util.List;
import
org.junit.Assert
;
import
org.junit.Test
;
import
de.hft.stuttgart.citydoctor2.datastructure.Building
;
import
de.hft.stuttgart.citydoctor2.datastructure.BuildingPart
;
import
de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry.Orientation
;
import
de.hft.stuttgart.citydoctor2.datastructure.GeometryType
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType
;
import
de.hft.stuttgart.citydoctor2.datastructure.Lod
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
...
...
@@ -87,4 +93,50 @@ public class AABBTest {
// edge point
Assert
.
assertTrue
(
aabb
.
contains
(
testOnEdgeX
,
testOnEdgeY
,
testOnEdgeZ
));
}
@Test
public
void
testAabbOfBuildingIncludesBuildingParts
()
{
Building
building
=
new
Building
();
building
.
addGeometry
(
singlePolygonGeometry
(
0.0
,
0.0
,
0.0
,
1.0
,
1.0
,
1.0
));
BuildingPart
part
=
new
BuildingPart
(
building
);
part
.
addGeometry
(
singlePolygonGeometry
(
10.0
,
20.0
,
5.0
,
11.0
,
21.0
,
6.0
));
AABB
buildingBox
=
AABB
.
of
(
building
);
Assert
.
assertEquals
(
0.0
,
buildingBox
.
getMinX
(),
0.0
);
Assert
.
assertEquals
(
0.0
,
buildingBox
.
getMinY
(),
0.0
);
Assert
.
assertEquals
(
0.0
,
buildingBox
.
getMinZ
(),
0.0
);
Assert
.
assertEquals
(
11.0
,
buildingBox
.
getMaxX
(),
0.0
);
Assert
.
assertEquals
(
21.0
,
buildingBox
.
getMaxY
(),
0.0
);
Assert
.
assertEquals
(
6.0
,
buildingBox
.
getMaxZ
(),
0.0
);
AABB
partBox
=
AABB
.
of
(
part
);
Assert
.
assertEquals
(
10.0
,
partBox
.
getMinX
(),
0.0
);
Assert
.
assertEquals
(
20.0
,
partBox
.
getMinY
(),
0.0
);
Assert
.
assertEquals
(
5.0
,
partBox
.
getMinZ
(),
0.0
);
Assert
.
assertEquals
(
11.0
,
partBox
.
getMaxX
(),
0.0
);
Assert
.
assertEquals
(
21.0
,
partBox
.
getMaxY
(),
0.0
);
Assert
.
assertEquals
(
6.0
,
partBox
.
getMaxZ
(),
0.0
);
}
private
static
Geometry
singlePolygonGeometry
(
double
minX
,
double
minY
,
double
minZ
,
double
maxX
,
double
maxY
,
double
maxZ
)
{
Geometry
geometry
=
new
Geometry
(
GeometryType
.
MULTI_SURFACE
,
Lod
.
LOD2
,
Orientation
.
OUTWARD
);
ConcretePolygon
polygon
=
new
ConcretePolygon
();
LinearRing
ring
=
new
LinearRing
(
LinearRingType
.
EXTERIOR
);
ring
.
addVertex
(
new
Vertex
(
minX
,
minY
,
minZ
));
ring
.
addVertex
(
new
Vertex
(
maxX
,
minY
,
minZ
));
ring
.
addVertex
(
new
Vertex
(
maxX
,
maxY
,
maxZ
));
ring
.
addVertex
(
new
Vertex
(
minX
,
maxY
,
maxZ
));
ring
.
addVertex
(
new
Vertex
(
minX
,
minY
,
minZ
));
polygon
.
setExteriorRing
(
ring
);
geometry
.
addPolygon
(
polygon
);
geometry
.
updateVertices
();
return
geometry
;
}
}
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