Moved the Rectangle and Line classes and the geometry utility
functions into the "tg" namespace to avoid conflicts with Windows headers.
This commit is contained in:
parent
232d51333c
commit
fe95a6aab4
9 changed files with 49 additions and 28 deletions
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "line.hxx"
|
||||
|
||||
namespace tg {
|
||||
|
||||
Line::Line ()
|
||||
{
|
||||
}
|
||||
|
@ -73,4 +75,6 @@ Line::getBounds () const
|
|||
return bounds;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// end of line.cxx
|
||||
|
|
|
@ -19,6 +19,7 @@ SG_USING_STD(vector);
|
|||
|
||||
#include "rectangle.hxx"
|
||||
|
||||
namespace tg {
|
||||
|
||||
/**
|
||||
* A simple multi-segment line class.
|
||||
|
@ -87,4 +88,6 @@ private:
|
|||
vector<Point3D> _points;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // __LINE_HXX
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "rectangle.hxx"
|
||||
|
||||
namespace tg {
|
||||
|
||||
Rectangle::Rectangle ()
|
||||
{
|
||||
}
|
||||
|
@ -81,4 +83,6 @@ Rectangle::toPoly () const
|
|||
return poly;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// end of rectangle.cxx
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
namespace tg {
|
||||
|
||||
/**
|
||||
* A simple rectangle class for bounding rectanglees.
|
||||
|
@ -132,4 +133,6 @@ private:
|
|||
Point3D _max;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // __RECTANGLE_HXX
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
namespace tg {
|
||||
|
||||
|
||||
bool
|
||||
getIntersection (const Point3D &p0, const Point3D &p1,
|
||||
|
@ -205,4 +207,6 @@ parseChunk (const string &s)
|
|||
return bounds;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// end of util.cxx
|
||||
|
|
|
@ -21,6 +21,8 @@ SG_USING_STD(string);
|
|||
|
||||
#include "line.hxx"
|
||||
|
||||
namespace tg {
|
||||
|
||||
|
||||
/**
|
||||
* Inline function to clamp an angle between 0 and 360 degrees.
|
||||
|
@ -104,5 +106,6 @@ Rectangle makeBounds (const FGPolygon &polygon);
|
|||
*/
|
||||
Rectangle parseChunk (const string &s);
|
||||
|
||||
};
|
||||
|
||||
#endif // __UTIL_HXX
|
||||
|
|
|
@ -65,7 +65,7 @@ SG_USING_STD(vector);
|
|||
/**
|
||||
* Make a bounding box for a single ARC.
|
||||
*/
|
||||
static const Rectangle
|
||||
static const tg::Rectangle
|
||||
makeBounds (const E00::ARC &arc)
|
||||
{
|
||||
Point3D min, max;
|
||||
|
@ -81,17 +81,17 @@ makeBounds (const E00::ARC &arc)
|
|||
if (y > max.y()) max.sety(y);
|
||||
}
|
||||
}
|
||||
return Rectangle(min, max);
|
||||
return tg::Rectangle(min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a bounding box for a polygon.
|
||||
*/
|
||||
static const Rectangle
|
||||
static const tg::Rectangle
|
||||
makeBounds (const E00::PAL &pal)
|
||||
{
|
||||
return Rectangle(Point3D(pal.min.x, pal.min.y, 0),
|
||||
Point3D(pal.max.x, pal.max.y, 0));
|
||||
return tg::Rectangle(Point3D(pal.min.x, pal.min.y, 0),
|
||||
Point3D(pal.max.x, pal.max.y, 0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,7 +163,7 @@ checkAttribute (const E00 &data, int index, const Attribute &att)
|
|||
* uses the WGS80 functions, rather than simple Pythagorean stuff.
|
||||
*/
|
||||
static void
|
||||
processPoints (const E00 &data, const Rectangle &bounds,
|
||||
processPoints (const E00 &data, const tg::Rectangle &bounds,
|
||||
AreaType areaType, const string &workDir, int width)
|
||||
{
|
||||
double x, y, az;
|
||||
|
@ -180,7 +180,7 @@ processPoints (const E00 &data, const Rectangle &bounds,
|
|||
continue;
|
||||
}
|
||||
|
||||
makePolygon(p, width, shape);
|
||||
tg::makePolygon(p, width, shape);
|
||||
split_polygon(workDir, areaType, shape);
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ processPoints (const E00 &data, const Rectangle &bounds,
|
|||
* uses the WGS80 functions, rather than simple Pythagorean stuff.
|
||||
*/
|
||||
static void
|
||||
processLines (const E00 &data, const Rectangle &bounds,
|
||||
processLines (const E00 &data, const tg::Rectangle &bounds,
|
||||
AreaType areaType, const string &workDir, int width,
|
||||
const vector<Attribute> &aat_list)
|
||||
{
|
||||
|
@ -205,7 +205,7 @@ processLines (const E00 &data, const Rectangle &bounds,
|
|||
for (int i = 1; i <= nLines; i++) {
|
||||
FGPolygon shape;
|
||||
const E00::ARC &arc = data.getARC(i);
|
||||
Rectangle arcBounds = makeBounds(arc);
|
||||
tg::Rectangle arcBounds = makeBounds(arc);
|
||||
if (!bounds.isOverlapping(arcBounds)) {
|
||||
cout << "Arc " << i << " outside of area; skipping" << endl;
|
||||
continue;
|
||||
|
@ -228,7 +228,7 @@ processLines (const E00 &data, const Rectangle &bounds,
|
|||
}
|
||||
}
|
||||
|
||||
Line line;
|
||||
tg::Line line;
|
||||
int j;
|
||||
for (j = 0; j < arc.numberOfCoordinates; j++) {
|
||||
line.addPoint(Point3D(arc.coordinates[j].x,
|
||||
|
@ -236,7 +236,7 @@ processLines (const E00 &data, const Rectangle &bounds,
|
|||
0));
|
||||
}
|
||||
|
||||
makePolygon(line, width, shape);
|
||||
tg::makePolygon(line, width, shape);
|
||||
|
||||
// Split into tiles
|
||||
cout << "Splitting polygon..." << endl;
|
||||
|
@ -254,7 +254,7 @@ processLines (const E00 &data, const Rectangle &bounds,
|
|||
* Import all polygons.
|
||||
*/
|
||||
static void
|
||||
processPolygons (const E00 &data, const Rectangle &bounds,
|
||||
processPolygons (const E00 &data, const tg::Rectangle &bounds,
|
||||
AreaType areaType, const string &workDir,
|
||||
const vector<Attribute> pat_list)
|
||||
{
|
||||
|
@ -283,7 +283,7 @@ processPolygons (const E00 &data, const Rectangle &bounds,
|
|||
|
||||
int contour = 0;
|
||||
const E00::PAL &pal = data.getPAL(i);
|
||||
Rectangle palBounds = makeBounds(pal);
|
||||
tg::Rectangle palBounds = makeBounds(pal);
|
||||
if (!bounds.isOverlapping(palBounds)) {
|
||||
cout << "Polygon " << i << " outside of area, skipping" << endl;
|
||||
continue;
|
||||
|
@ -381,7 +381,7 @@ main (int argc, const char **argv)
|
|||
|
||||
|
||||
// Default values
|
||||
Rectangle bounds(Point3D(-180.0, -90.0, 0),
|
||||
tg::Rectangle bounds(Point3D(-180.0, -90.0, 0),
|
||||
Point3D(180.0, 90.0, 0));
|
||||
AreaType areaType = DefaultArea;
|
||||
int pointWidth = 500;
|
||||
|
|
|
@ -83,10 +83,10 @@ vpf2tg (const VpfPoint &p)
|
|||
/**
|
||||
* Convert a VPF line to a regular TerraGear line.
|
||||
*/
|
||||
static const Line
|
||||
static const tg::Line
|
||||
vpf2tg (const VpfLine &l)
|
||||
{
|
||||
Line result;
|
||||
tg::Line result;
|
||||
int nPoints = l.getPointCount();
|
||||
for (int i = 0; i < nPoints; i++)
|
||||
result.addPoint(vpf2tg(l.getPoint(i)));
|
||||
|
@ -97,10 +97,10 @@ vpf2tg (const VpfLine &l)
|
|||
/**
|
||||
* Convert a VPF rectangle to a TerraGear rectangle.
|
||||
*/
|
||||
static inline const Rectangle
|
||||
static inline const tg::Rectangle
|
||||
vpf2tg (const VpfRectangle &rect)
|
||||
{
|
||||
return Rectangle(Point3D(rect.minX, rect.minY, 0),
|
||||
return tg::Rectangle(Point3D(rect.minX, rect.minY, 0),
|
||||
Point3D(rect.maxX, rect.maxY, 0));
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ checkAttribute (const VpfFeature &feature, int index, const Attribute &att)
|
|||
static double
|
||||
getArea (const FGPolygon &polygon)
|
||||
{
|
||||
Rectangle bounds = makeBounds(polygon);
|
||||
tg::Rectangle bounds = tg::makeBounds(polygon);
|
||||
Point3D min =
|
||||
sgGeodToCart(Point3D(bounds.getMin().x() * SGD_DEGREES_TO_RADIANS,
|
||||
bounds.getMin().y() * SGD_DEGREES_TO_RADIANS,
|
||||
|
@ -281,7 +281,7 @@ main (int argc, const char **argv)
|
|||
|
||||
|
||||
// Default values
|
||||
Rectangle bounds(Point3D(-180, -90, 0), Point3D(180, 90, 0));
|
||||
tg::Rectangle bounds(Point3D(-180, -90, 0), Point3D(180, 90, 0));
|
||||
bool invert = false;
|
||||
AreaType material_type = DefaultArea;
|
||||
int width = -1; // use default
|
||||
|
@ -298,7 +298,7 @@ main (int argc, const char **argv)
|
|||
string arg = argv[argPos];
|
||||
|
||||
if (arg.find("--chunk=") == 0) {
|
||||
bounds = parseChunk(arg.substr(8));
|
||||
bounds = tg::parseChunk(arg.substr(8));
|
||||
argPos++;
|
||||
}
|
||||
|
||||
|
@ -478,11 +478,11 @@ main (int argc, const char **argv)
|
|||
const Point3D p = vpf2tg(feature.getPoint(i));
|
||||
if (!bounds.isInside(p))
|
||||
continue;
|
||||
makePolygon(p, (width == -1 ? 500 : width), shape);
|
||||
tg::makePolygon(p, (width == -1 ? 500 : width), shape);
|
||||
break;
|
||||
}
|
||||
case VpfFeature::LINE: {
|
||||
const Line line = vpf2tg(feature.getLine(i));
|
||||
const tg::Line line = vpf2tg(feature.getLine(i));
|
||||
if (!bounds.isOverlapping(line.getBounds()))
|
||||
continue;
|
||||
makePolygon(line, (width == -1 ? 50 : width), shape);
|
||||
|
@ -507,7 +507,7 @@ main (int argc, const char **argv)
|
|||
const Point3D p = vpf2tg(feature.getLabel(i).getPoint());
|
||||
if (!bounds.isInside(p))
|
||||
continue;
|
||||
makePolygon(p, (width == -1 ? 500 : width), shape);
|
||||
tg::makePolygon(p, (width == -1 ? 500 : width), shape);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -21,7 +21,7 @@ SG_USING_STD(vector);
|
|||
|
||||
static string prog_name;
|
||||
static string work_dir = ".";
|
||||
static Rectangle bounds(Point3D(-180, -90, 0), Point3D(180, 90, 0));
|
||||
static tg::Rectangle bounds(Point3D(-180, -90, 0), Point3D(180, 90, 0));
|
||||
static FGPolygon bounds_poly;
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ add_point (SGPropertyNode_ptr node)
|
|||
if (s != 0)
|
||||
SG_LOG(SG_TERRAIN, SG_WARN, "More than one vertex supplied for point");
|
||||
FGPolygon poly;
|
||||
makePolygon(p, node->getIntValue("width", 500), poly);
|
||||
tg::makePolygon(p, node->getIntValue("width", 500), poly);
|
||||
poly = polygon_int(poly, bounds_poly);
|
||||
split_polygon(".", material, poly);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ add_line (SGPropertyNode_ptr node)
|
|||
const char * s = node->getStringValue("v");
|
||||
|
||||
Point3D p;
|
||||
Line line;
|
||||
tg::Line line;
|
||||
s = parse_point(s, p);
|
||||
while (s != 0) {
|
||||
line.addPoint(p);
|
||||
|
@ -135,7 +135,7 @@ main (int ac, char ** av)
|
|||
string arg = av[argPos];
|
||||
|
||||
if (arg.find("--chunk=") == 0) {
|
||||
bounds = parseChunk(arg.substr(8));
|
||||
bounds = tg::parseChunk(arg.substr(8));
|
||||
argPos++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue