Bounding Box Calculation Library

From SIMSTADT
Jump to: navigation, search

Contents

[edit] Usage

This API is designed to generate a bounding box (BB) of 3D objects/buildings. It offers five strategies to calculate the BBs. You can compute axis-aligned and object-oriented BBs. Object-oriented BBs align to the 3D geometry of the object. Once you computed the BB you can obtain its geometry and volume.

[edit] Methodology

The client application has to implement the IBoundingBoxModelAdaptor interface to convert the geometry of the native model. The API offers various strategies to calculate a BB. The Principal Component strategy is based on the maximum spread of the vertices. The Longest Edge strategy aligns the BB to the maximum length edge in three dimensions. Notice that vertical/almost vertical edges are filtered out during the calculation. The Projected Edge strategy aligns the BB to the maximum length edge projected on the XY plane. The Largest Polygon strategy aligns the BB to the maximum area polygon. Notice that horizontal/almost horizontal polygons are filtered out and the API assumes that the polygons of the model are planar. The Axis Aligned strategy generates a BB aligned to the axes of the coordinate system in use.

[edit] Instructions

[edit] Implement the IBoundingBoxModelAdaptor

Create a wrapper class that implements the IBoundingBoxModelAdaptor interface. Then implement each abstract method in order to convert the native data model of the object/building to a model that the API understands i.e. convert the vertices, the edges and the polygons.

double[] getVertices() for example [x0 y0 z0 x1 y1 z1 x2 y2 z2...]

double[] getEdges() for example [x0 y0 z0 x1 y1 z1 x1 y1 z1 x2 y2 z2...]

ArrayList<double[]> getFaces() for example 
Polygon 1 [x0 y0 z0 x1 y1 z1 x2 y2 z2 x3 y3 z3]
Polygon 2 [x4 y4 z4 x3 y3 z3 x5 y5 z5 x6 y6 z6] note that the first vertex of a polygon is not repeated
Polygon...

[edit] Pick a calculation strategy

Select a calculation strategy for the BB. So far five strategies exist, the principal component, the longest edge, the projected edge, the largest polygon and the axis aligned.

// The NativeModelWrapper implements the IBoundingBoxModelAdaptor interface
NativeModelWrapper mw = new NativeModelWrapper(NativeModel);
LargestPolygonStrategy lp = new LargestPolygonStrategy();
BoundingBox bb = new BoundingBox(mw, lp);

// BB with principal component strategy
PrincipalComponentStrategy pc = new PrincipalComponentStrategy();
BoundingBox bb = new BoundingBox(mw, pc);

// BB with longest edge strategy
LongestEdgeStrategy le = new LongestEdgeStrategy();
BoundingBox bb = new BoundingBox(mw, le);

// BB with projected edge strategy
ProjectedEdgeStrategy pe = new ProjectedEdgeStrategy();
BoundingBox bb = new BoundingBox(mw, pe);

// BB with axis aligned strategy
AxisAlignedStrategy aa = new AxisAlignedStrategy();
BoundingBox bb = new BoundingBox(mw, aa);

// If no strategy is passed in the constructor, the axis aligned strategy is used by default
BoundingBox bb = new BoundingBox(mw);

// The calculation strategy can change at runtime
bb.setCalculationStrategy(new LongestEdgeStrategy());

[edit] Calculate a BB object

Figure 1: Ordered corners of a bounding box.

Calculate a BB object. The vertices of the BB can be queried by the use of an index or an enumeration.

Query BB vertices
Using indexes Using enumerations
0 BOTTOM_FRONT_RIGHT
1 BOTTOM_BACK_RIGHT
2 BOTTOM_BACK_LEFT
3 BOTTOM_FRONT_LEFT
4 TOP_FRONT_RIGHT
5 TOP_BACK_RIGHT
6 TOP_BACK_LEFT
7 TOP_FRONT_LEFT
// The calculate method throws a BoundingBoxException
try {
    bb.calculate();
} catch (BoundingBoxException e) {
    e.printStackTrace();
}

// Access the first vertex of the BB using both ways
double[] v0byIndex = bb.getCorner(0);
double[] v0byEnum = bb.getCorner(Corner3d.BOTTOM_FRONT_RIGHT);

// Access all vertices of the BB
ArrayList<double[]> vertices = bb.getAllCorners();

// Get the volume of the BB
System.out.println(bb.volume());

[edit] Evaluation of the different calculation strategies

Picture 1: Bounding boxes of buildings calculated with different strategies. Red layer: principle component, green layer: longest edge, yellow layer: axis-aligned.

We wanted to learn the average difference between building volumes and corresponding bounding box volumes. Furthermore, we wanted to know which calculation strategy performs best for a given set of buildings. We tested with 2200 buildings from Wüstenrot in LOD2 / Multisurface.

Additionally carried out an analysis on which strategy gives the lowest average volume for different city models.

Average BB volume (m3), lower is better
City Model Principal Component Longest Edge Projected Edge Largest Polygon Axis Aligned
LOD2_820_Wuestenrot.gml 1153 994 986 1012 1394
LOD2_821_Finsterrot.gml 975 830 825 834 1237
LOD2_822_Maienfels.gml 927 808 801 804 1219
LOD2_823_Neuhuetten.gml 1067 904 899 914 1302
LOD2_824_Neulautern.gml 931 810 807 810 1211

In all city models the projected edge strategy gives the lowest average volume for all the calculated BBs. Note that in some cases two or more strategies give the same BB/volume for the same building.

[edit] Links

Short manual (pdf)
Principal Component Analysis

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox