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
6e94b4c8
Commit
6e94b4c8
authored
Jul 15, 2025
by
Riegel
Browse files
Fix: BoundingBoxCalculator not including BoundarySurfaces
parent
aa9c2a95
Changes
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/BoundingBoxCalculator.java
View file @
6e94b4c8
...
@@ -26,12 +26,9 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
...
@@ -26,12 +26,9 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.TopLevelTransportFeature
;
import
de.hft.stuttgart.citydoctor2.datastructure.TrafficSpaceObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.TransportationObject
;
import
de.hft.stuttgart.citydoctor2.datastructure.TransportationSpace
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.CityObjectCollector
;
/**
/**
* Utility class for calculating axis aligned bounding boxes for different
* Utility class for calculating axis aligned bounding boxes for different
...
@@ -99,14 +96,13 @@ public class BoundingBoxCalculator {
...
@@ -99,14 +96,13 @@ public class BoundingBoxCalculator {
* @return the bounding box of the model
* @return the bounding box of the model
*/
*/
public
static
BoundingBox
calculateBoundingBox
(
CityDoctorModel
model
)
{
public
static
BoundingBox
calculateBoundingBox
(
CityDoctorModel
model
)
{
Vector3d
low
=
new
Vector3d
(
Double
.
MAX_VALUE
,
Double
.
MAX_VALUE
,
Double
.
MAX_VALUE
);
Vector3d
low
=
new
Vector3d
(
Double
.
POSITIVE_INFINITY
,
Double
.
POSITIVE_INFINITY
,
Double
.
POSITIVE_INFINITY
);
Vector3d
high
=
new
Vector3d
(
Double
.
NEGATIVE_INFINITY
,
Double
.
NEGATIVE_INFINITY
,
Double
.
NEGATIVE_INFINITY
);
Vector3d
high
=
new
Vector3d
(
Double
.
NEGATIVE_INFINITY
,
Double
.
NEGATIVE_INFINITY
,
Double
.
NEGATIVE_INFINITY
);
//TODO: Rework this using visitors
findMinMax
(
low
,
high
,
model
.
getBuildings
());
findMinMax
(
low
,
high
,
model
.
getBuildings
());
findMinMax
(
low
,
high
,
model
.
getBridges
());
findMinMax
(
low
,
high
,
model
.
getBridges
());
findMinMax
(
low
,
high
,
model
.
getLand
());
findMinMax
(
low
,
high
,
model
.
getLand
());
findMinMax
Transport
(
low
,
high
,
model
.
getTransportation
());
findMinMax
(
low
,
high
,
model
.
getTransportation
());
findMinMax
(
low
,
high
,
model
.
getWater
());
findMinMax
(
low
,
high
,
model
.
getWater
());
findMinMax
(
low
,
high
,
model
.
getVegetation
());
findMinMax
(
low
,
high
,
model
.
getVegetation
());
findMinMax
(
low
,
high
,
model
.
getTunnels
());
findMinMax
(
low
,
high
,
model
.
getTunnels
());
...
@@ -159,47 +155,39 @@ public class BoundingBoxCalculator {
...
@@ -159,47 +155,39 @@ public class BoundingBoxCalculator {
}
}
}
}
//TODO: Implement this properly with visitor. Quick and dirty fix for the renderer
private
static
void
findMinMaxTransport
(
Vector3d
low
,
Vector3d
high
,
List
<?
extends
TransportationObject
>
features
)
{
private
static
void
findMinMax
(
Vector3d
low
,
Vector3d
high
,
CityObject
co
)
{
for
(
TransportationObject
to
:
features
)
{
CityObjectCollector
collector
=
new
CityObjectCollector
();
findMinMax
(
low
,
high
,
to
);
co
.
accept
(
collector
);
if
(
to
instanceof
TransportationSpace
ts
)
{
for
(
CityObject
object
:
collector
.
getCityObjects
())
{
findMinMaxTransport
(
low
,
high
,
ts
.
getTrafficSpaces
());
for
(
Geometry
geom
:
object
.
getGeometries
())
{
findMinMaxTransport
(
low
,
high
,
ts
.
getAuxTrafficSpaces
());
if
(
geom
.
getVertices
()
==
null
)
{
if
(
to
instanceof
TopLevelTransportFeature
top
)
{
geom
.
updateVertices
();
findMinMaxTransport
(
low
,
high
,
top
.
getSections
());
findMinMaxTransport
(
low
,
high
,
top
.
getIntersections
());
}
}
}
else
if
(
to
instanceof
TrafficSpaceObject
tso
)
{
findMinMax
(
low
,
high
,
geom
);
findMinMaxTransport
(
low
,
high
,
tso
.
getTrafficAreas
());
}
}
}
}
}
}
private
static
void
findMinMax
(
Vector3d
low
,
Vector3d
high
,
CityObject
co
)
{
private
static
void
findMinMax
(
Vector3d
low
,
Vector3d
high
,
Geometry
geom
)
{
for
(
Geometry
geom
:
co
.
getGeometri
es
())
{
for
(
Vertex
v
:
geom
.
getVertic
es
())
{
if
(
geom
.
getVertices
()
==
null
)
{
if
(
v
.
getX
()
<
low
.
getX
()
)
{
geom
.
updateVertices
(
);
low
.
setX
(
v
.
getX
()
);
}
}
for
(
Vertex
v
:
geom
.
getVertices
())
{
if
(
v
.
getX
()
>
high
.
getX
())
{
if
(
v
.
getX
()
<
low
.
getX
())
{
high
.
setX
(
v
.
getX
());
low
.
setX
(
v
.
getX
());
}
}
if
(
v
.
getY
()
<
low
.
getY
())
{
if
(
v
.
getX
()
>
high
.
getX
())
{
low
.
setY
(
v
.
getY
());
high
.
setX
(
v
.
getX
());
}
}
if
(
v
.
getY
()
>
high
.
getY
())
{
if
(
v
.
getY
()
<
low
.
getY
())
{
high
.
setY
(
v
.
getY
());
low
.
setY
(
v
.
getY
());
}
}
if
(
v
.
getZ
()
<
low
.
getZ
())
{
if
(
v
.
getY
()
>
high
.
getY
())
{
low
.
setZ
(
v
.
getZ
());
high
.
setY
(
v
.
getY
());
}
}
if
(
v
.
getZ
()
>
high
.
getZ
())
{
if
(
v
.
getZ
()
<
low
.
getZ
())
{
high
.
setZ
(
v
.
getZ
());
low
.
setZ
(
v
.
getZ
());
}
if
(
v
.
getZ
()
>
high
.
getZ
())
{
high
.
setZ
(
v
.
getZ
());
}
}
}
}
}
}
}
...
...
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