force explicit types

This commit is contained in:
Konstantin Käfer
2014-03-17 16:58:04 +01:00
parent bf6a6001f9
commit bed8de2ad6
3 changed files with 19 additions and 16 deletions

View File

@@ -12,9 +12,9 @@ namespace llmr {
// These are the glyph boxes that we want to have placed.
struct GlyphBox {
GlyphBox() {}
GlyphBox(const CollisionRect &bbox, const CollisionRect &box,
float minScale)
explicit GlyphBox() {}
explicit GlyphBox(const CollisionRect &bbox, const CollisionRect &box,
float minScale)
: bbox(bbox), box(box), minScale(minScale) {}
CollisionAnchor anchor;
@@ -40,8 +40,8 @@ struct PlacementBox {
};
struct Placement {
Placement() {}
Placement(float zoom, const PlacementRange &rotationRange)
explicit Placement() {}
explicit Placement(float zoom, const PlacementRange &rotationRange)
: zoom(zoom), rotationRange(rotationRange) {}
float zoom = -1.0f;
@@ -56,7 +56,7 @@ class Collision {
typedef boost::geometry::index::rtree<
PlacementValue, boost::geometry::index::quadratic<16>> Tree;
public:
public:
Collision();
Placement place(const GlyphBoxes &boxes, const CollisionAnchor &anchor,
@@ -70,9 +70,9 @@ class Collision {
float placementScale, const PlacementRange &placementRange,
bool horizontal, float padding);
private:
private:
Tree tree;
};
}
#endif
#endif

View File

@@ -23,11 +23,14 @@ typedef std::array<CollisionPoint, 4> CollisionCorners;
struct CollisionRect {
CollisionPoint tl;
CollisionPoint br;
inline CollisionRect() {}
inline CollisionRect(CollisionPoint::Type ax, CollisionPoint::Type ay,
CollisionPoint::Type bx, CollisionPoint::Type by)
inline explicit CollisionRect() {}
inline explicit CollisionRect(CollisionPoint::Type ax,
CollisionPoint::Type ay,
CollisionPoint::Type bx,
CollisionPoint::Type by)
: tl(ax, ay), br(bx, by) {}
inline CollisionRect(const CollisionPoint &tl, const CollisionPoint &br)
inline explicit CollisionRect(const CollisionPoint &tl,
const CollisionPoint &br)
: tl(tl), br(br) {}
};

View File

@@ -32,7 +32,7 @@ GlyphBox getMergedGlyphs(const GlyphBoxes &glyphs, bool horizontal,
const CollisionAnchor &anchor) {
GlyphBox mergedGlyphs;
const float inf = std::numeric_limits<float>::infinity();
mergedGlyphs.box = {{inf, inf}, {-inf, -inf}};
mergedGlyphs.box = CollisionRect{{inf, inf}, {-inf, -inf}};
mergedGlyphs.rotate = horizontal;
mergedGlyphs.anchor = anchor;
@@ -80,7 +80,7 @@ Placement Collision::place(const GlyphBoxes &boxes,
diag = sqrt(
util::max(x12 + y12, x12 + y22, x22 + y12, x22 + y22));
glyph.bbox = {{-diag, -diag}, {diag, diag}};
glyph.bbox = CollisionRect{{-diag, -diag}, {diag, diag}};
} else {
glyph.bbox = glyph.box;
}
@@ -93,7 +93,7 @@ Placement Collision::place(const GlyphBoxes &boxes,
// Return if the label can never be placed without collision
if (scale < 0)
return {};
return Placement{};
// Calculate the range it is safe to rotate all glyphs
PlacementRange rotationRange = getPlacementRange(glyphs, scale);
@@ -101,7 +101,7 @@ Placement Collision::place(const GlyphBoxes &boxes,
float zoom = log(scale) / log(2);
return {zoom, rotationRange};
return Placement{zoom, rotationRange};
}
float Collision::getPlacementScale(const GlyphBoxes &glyphs,