1
0
Fork 0

genapts linearfeatures: Remove more Point3D occurences

This commit is contained in:
Christian Schmitt 2012-11-18 17:11:56 +01:00
parent 05091265a5
commit c9f79718fa
2 changed files with 48 additions and 55 deletions

View file

@ -1,14 +1,11 @@
#include <stdlib.h>
#include <simgear/math/sg_geodesy.hxx>
#include <Geometry/poly_support.hxx>
#include <Geometry/util.hxx>
#include "global.hxx"
#include "beznode.hxx"
#include "linearfeature.hxx"
#include "math.h"
void LinearFeature::ConvertContour( BezContour* src, bool closed )
{
@ -31,7 +28,7 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
SG_LOG(SG_GENERAL, SG_DEBUG, " LinearFeature::ConvertContour - Creating a contour with " << src->size() << " nodes");
// clear anything in the point list
points.empty();
points.Erase();
// iterate through each bezier node in the contour
for (unsigned int i=0; i <= src->size()-1; i++)
@ -56,10 +53,10 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
{
if (curNode->GetMarking() != cur_mark->type)
{
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Marking has changed from " << cur_mark->type << " to " << curNode->GetMarking() << " save mark from " << cur_mark->start_idx << " to " << points.size() );
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Marking has changed from " << cur_mark->type << " to " << curNode->GetMarking() << " save mark from " << cur_mark->start_idx << " to " << points.GetSize() );
// marking has ended, or changed
cur_mark->end_idx = points.size();
cur_mark->end_idx = points.GetSize();
marks.push_back(cur_mark);
cur_mark = NULL;
}
@ -74,12 +71,12 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
{
if (curNode->GetMarking())
{
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Start Marking from " << points.size() << " with type " << curNode->GetMarking() );
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Start Marking from " << points.GetSize() << " with type " << curNode->GetMarking() );
// we aren't watching a mark, and this node has one
cur_mark = new Marking;
cur_mark->type = curNode->GetMarking();
cur_mark->start_idx = points.size();
cur_mark->start_idx = points.GetSize();
}
}
////////////////////////////////////////////////////////////////////////////////////
@ -93,10 +90,10 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
{
if (curNode->GetLighting() != cur_light->type)
{
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Lighting has changed from " << cur_light->type << " to " << curNode->GetLighting() << " save light from " << cur_light->start_idx << " to " << points.size() );
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Lighting has changed from " << cur_light->type << " to " << curNode->GetLighting() << " save light from " << cur_light->start_idx << " to " << points.GetSize() );
// lighting has ended, or changed : add final light
cur_light->end_idx = points.size();
cur_light->end_idx = points.GetSize();
lights.push_back(cur_light);
cur_light = NULL;
}
@ -111,12 +108,12 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
{
if (curNode->GetLighting())
{
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Start Lighting from " << points.size() << " with type " << curNode->GetLighting() );
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Start Lighting from " << points.GetSize() << " with type " << curNode->GetLighting() );
// we aren't watching a mark, and this node has one
cur_light = new Lighting;
cur_light->type = curNode->GetLighting();
cur_light->start_idx = points.size();
cur_light->start_idx = points.GetSize();
}
}
////////////////////////////////////////////////////////////////////////////////////
@ -271,7 +268,7 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
}
// add the feature vertex
points.push_back( Point3D::fromSGGeod(curLoc) );
points.AddNode(curLoc);
if (p==0)
{
@ -297,7 +294,7 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
nextLoc = CalculateLinearLocation( curNode->GetLoc(), nextNode->GetLoc(), (1.0f/num_segs) * (p+1) );
// add the feature vertex
points.push_back( Point3D::fromSGGeod(curLoc) );
points.AddNode(curLoc);
if (p==0)
{
@ -317,7 +314,7 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
nextLoc = nextNode->GetLoc();
// just add the one vertex - dist is small
points.push_back( Point3D::fromSGGeod(curLoc) );
points.AddNode(curLoc);
SG_LOG(SG_GENERAL, SG_DEBUG, "adding Linear Anchor node at " << curLoc );
@ -331,15 +328,15 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
SG_LOG(SG_GENERAL, SG_DEBUG, "Closed COntour : adding last node at " << curLoc );
// need to add the markings for last segment
points.push_back( Point3D::fromSGGeod(curLoc) );
points.AddNode(curLoc);
}
// check for marking that goes all the way to the end...
if (cur_mark)
{
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Marking from " << cur_mark->start_idx << " with type " << cur_mark->type << " ends at the end of the contour: " << points.size() );
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Marking from " << cur_mark->start_idx << " with type " << cur_mark->type << " ends at the end of the contour: " << points.GetSize() );
cur_mark->end_idx = points.size()-1;
cur_mark->end_idx = points.GetSize()-1;
marks.push_back(cur_mark);
cur_mark = NULL;
}
@ -347,9 +344,9 @@ void LinearFeature::ConvertContour( BezContour* src, bool closed )
// check for lighting that goes all the way to the end...
if (cur_light)
{
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Lighting from " << cur_light->start_idx << " with type " << cur_light->type << " ends at the end of the contour: " << points.size() );
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::ConvertContour Lighting from " << cur_light->start_idx << " with type " << cur_light->type << " ends at the end of the contour: " << points.GetSize() );
cur_light->end_idx = points.size()-1;
cur_light->end_idx = points.GetSize()-1;
lights.push_back(cur_light);
cur_light = NULL;
}
@ -622,19 +619,19 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
if (j == marks[i]->start_idx)
{
// first point on the mark - offset heading is 90deg
cur_outer = OffsetPointFirst( points[j].toSGGeod(), points[j+1].toSGGeod(), offset-width/2.0f );
cur_inner = OffsetPointFirst( points[j].toSGGeod(), points[j+1].toSGGeod(), offset+width/2.0f );
cur_outer = OffsetPointFirst( points.GetNode(j), points.GetNode(j+1), offset-width/2.0f );
cur_inner = OffsetPointFirst( points.GetNode(j), points.GetNode(j+1), offset+width/2.0f );
}
else if (j == marks[i]->end_idx)
{
// last point on the mark - offset heading is 90deg
cur_outer = OffsetPointLast( points[j-1].toSGGeod(), points[j].toSGGeod(), offset-width/2.0f );
cur_inner = OffsetPointLast( points[j-1].toSGGeod(), points[j].toSGGeod(), offset+width/2.0f );
cur_outer = OffsetPointLast( points.GetNode(j-1), points.GetNode(j), offset-width/2.0f );
cur_inner = OffsetPointLast( points.GetNode(j-1), points.GetNode(j), offset+width/2.0f );
}
else
{
cur_outer = OffsetPointMiddle( points[j-1].toSGGeod(), points[j].toSGGeod(), points[j+1].toSGGeod(), offset-width/2.0f );
cur_inner = OffsetPointMiddle( points[j-1].toSGGeod(), points[j].toSGGeod(), points[j+1].toSGGeod(), offset+width/2.0f );
cur_outer = OffsetPointMiddle( points.GetNode(j-1), points.GetNode(j), points.GetNode(j+1), offset-width/2.0f );
cur_inner = OffsetPointMiddle( points.GetNode(j-1), points.GetNode(j), points.GetNode(j+1), offset+width/2.0f );
}
if ( markStarted )
@ -721,16 +718,16 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
if (j == lights[i]->start_idx)
{
// first point on the light - offset heading is 90deg
cur_outer = OffsetPointFirst( points[j].toSGGeod(), points[j+1].toSGGeod(), offset );
cur_outer = OffsetPointFirst( points.GetNode(j), points.GetNode(j+1), offset );
}
else if (j == lights[i]->end_idx)
{
// last point on the mark - offset heading is 90deg
cur_outer = OffsetPointLast( points[j-1].toSGGeod(), points[j].toSGGeod(), offset );
cur_outer = OffsetPointLast( points.GetNode(j-1), points.GetNode(j), offset );
}
else
{
cur_outer = OffsetPointMiddle( points[j-1].toSGGeod(), points[j].toSGGeod(), points[j+1].toSGGeod(), offset );
cur_outer = OffsetPointMiddle( points.GetNode(j-1), points.GetNode(j), points.GetNode(j+1), offset );
}
if ( markStarted )

View file

@ -2,10 +2,6 @@
#define _LINEARFEATURE_H_
#include <Polygon/polygon.hxx>
#include <Polygon/superpoly.hxx>
#include <Polygon/texparams.hxx>
#include <Geometry/point3d.hxx>
using std::string;
@ -122,7 +118,7 @@ private:
BezContour contour;
// contour definition after bezier interpolation
point_list points;
tgContour points;
tgpolygon_list marking_polys;
tglightcontour_list lighting_polys;