summaryrefslogtreecommitdiff
path: root/app/bin/trkseg.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-05-05 18:22:00 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-05-05 18:22:00 +0200
commit9a1d6eded2750572e9f5f79e53ec507dd7a06ba5 (patch)
tree10d84c82031aace7ac819f27116a04e7da238d59 /app/bin/trkseg.c
parentd1a8285f818eb7e5c3d6a05709ea21a808490b8c (diff)
New upstream version 5.1.1upstream/5.1.1
Diffstat (limited to 'app/bin/trkseg.c')
-rw-r--r--app/bin/trkseg.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/app/bin/trkseg.c b/app/bin/trkseg.c
index 9517a09..97de5e8 100644
--- a/app/bin/trkseg.c
+++ b/app/bin/trkseg.c
@@ -1131,7 +1131,7 @@ EXPORT BOOL_T ReadSegs( void )
int i;
DIST_T elev0, elev1;
BOOL_T hasElev;
- BOOL_T isPolyV2;
+ BOOL_T isPolyV2, noVersion;
BOOL_T improvedEnds;
FLOAT_T ignoreFloat;
char type;
@@ -1167,6 +1167,9 @@ EXPORT BOOL_T ReadSegs( void )
}
type = *cp++;
hasElev = FALSE;
+ noVersion = TRUE;
+ if ( *cp != ' ')
+ noVersion = FALSE;
if ( *cp == '3' ) {
cp++;
hasElev = TRUE;
@@ -1237,7 +1240,6 @@ EXPORT BOOL_T ReadSegs( void )
rc = FALSE;
break;
}
- rgb = 0;
s->color = wDrawFindColor( rgb );
break;
case SEG_CRVTRK:
@@ -1256,7 +1258,6 @@ EXPORT BOOL_T ReadSegs( void )
rc = FALSE;
break;
}
- rgb = 0;
s->color = wDrawFindColor( rgb );
break;
case SEG_JNTTRK:
@@ -1279,7 +1280,6 @@ EXPORT BOOL_T ReadSegs( void )
s->u.j.negate = ( option&1 )!=0;
s->u.j.flip = ( option&2 )!=0;
s->u.j.Scurve = ( option&4 )!=0;
- rgb = 0;
s->color = wDrawFindColor( rgb );
break;
case SEG_BEZTRK:
@@ -1298,7 +1298,6 @@ EXPORT BOOL_T ReadSegs( void )
rc = FALSE;
break;
}
- rgb = 0;
s->color = wDrawFindColor( rgb );
break;
case SEG_BEZLIN:
@@ -1340,6 +1339,7 @@ EXPORT BOOL_T ReadSegs( void )
DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 );
s = &tempSegs(tempSegs_da.cnt-1);
s->type = type;
+ s->u.p.polyType = FREEFORM;
if (isPolyV2) {
if ( !GetArgs( cp, "lwdd",
&rgb, &s->width,
@@ -1359,9 +1359,14 @@ EXPORT BOOL_T ReadSegs( void )
s->u.p.pts = (coOrd*)MyMalloc( s->u.p.cnt * sizeof *(coOrd*)NULL );
for ( i=0; i<s->u.p.cnt; i++ ) {
cp = GetNextLine();
- if (cp == NULL || !GetArgs( cp, hasElev?"pf":"pY", &s->u.p.pts[i], &elev0 ) ) {
+ if (cp == NULL || !GetArgs( cp, "p", &s->u.p.pts[i])) {
rc = FALSE;
- /*??*/break;
+ }
+ if (!noVersion) {
+ if (cp == NULL || !GetArgs( cp, hasElev?"f":"Y", &elev0 ) ) {
+ rc = FALSE;
+ /*??*/break;
+ }
}
}
s->u.p.angle = 0.0;
@@ -1505,8 +1510,8 @@ EXPORT BOOL_T WriteSegsEnd(
for ( i=0; i<segCnt; i++ ) {
switch ( segs[i].type ) {
case SEG_STRTRK:
- rc &= fprintf( f, "\t%c 0 %0.6f %0.6f %0.6f %0.6f %0.6f\n",
- segs[i].type, segs[i].width,
+ rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f\n",
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0;
break;
@@ -1532,16 +1537,16 @@ EXPORT BOOL_T WriteSegsEnd(
BenchOutputOption(segs[i].u.l.option) ) > 0;
break;
case SEG_CRVTRK:
- rc &= fprintf( f, "\t%c 0 %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n",
- segs[i].type, segs[i].width,
+ rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n",
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
segs[i].u.c.radius,
segs[i].u.c.center.x, segs[i].u.c.center.y,
segs[i].u.c.a0, segs[i].u.c.a1 ) > 0;
break;
case SEG_JNTTRK:
option = (segs[i].u.j.negate?1:0) + (segs[i].u.j.flip?2:0) + (segs[i].u.j.Scurve?4:0);
- rc &= fprintf( f, "\t%c 0 %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %ld\n",
- segs[i].type, segs[i].width,
+ rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %ld\n",
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
segs[i].u.j.pos.x, segs[i].u.j.pos.y,
segs[i].u.j.angle,
segs[i].u.j.l0,
@@ -1552,8 +1557,8 @@ EXPORT BOOL_T WriteSegsEnd(
break;
case SEG_BEZTRK:
case SEG_BEZLIN:
- rc &= fprintf( f, "\t%c3 0 %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n",
- segs[i].type, segs[i].width,
+ rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n",
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y,
segs[i].u.l.pos[2].x, segs[i].u.l.pos[2].y,
@@ -2013,6 +2018,11 @@ EXPORT void CleanSegs(dynArr_t * seg_p) {
t.bezSegs.max = 0;
t.bezSegs.ptr = NULL;
}
+ if (t.type == SEG_POLY || t.type == SEG_FILPOLY) {
+ if (t.u.p.pts) MyFree(t.u.p.pts);
+ t.u.p.cnt = 0;
+ t.u.p.pts = NULL;
+ }
}
seg_p->cnt = 0;
if (seg_p->ptr) MyFree(seg_p->ptr);
@@ -2020,4 +2030,16 @@ EXPORT void CleanSegs(dynArr_t * seg_p) {
seg_p->max = 0;
}
+EXPORT void CopyPoly(trkSeg_p p, wIndex_t segCnt) {
+ coOrd * newPts;
+ for (int i=0;i<segCnt;i++,p++) {
+ if (p->type == SEG_POLY || p->type == SEG_FILPOLY) {
+ newPts = memdup( p->u.p.pts, p->u.p.cnt*sizeof *(coOrd*)0 );
+ p->u.p.pts = newPts;
+ }
+ }
+}
+
+
+