GenericSpline *Parser::Parse_Spline() { GenericSpline * Old = nullptr; GenericSpline * New = nullptr; bool keepOld = true; int i = 0, splineTypeCount = 0; EXPRESS Express; int Terms, MaxTerms; double par; bool old_allow_id = Allow_Identifier_In_Call; Allow_Identifier_In_Call = false; MaxTerms = 2; /*Check for spline identifier*/ if (AllowToken(SPLINE_ID_TOKEN)) { Old = CurrentTokenDataPtr()->Clone(); i = Old->SplineEntries.size(); MaxTerms = Old->Terms; keepOld = false; } /* Determine or change the kind of spline */ EXPECT CASE(LINEAR_SPLINE_TOKEN) splineTypeCount++; if (splineTypeCount > 1) Error("linear_spline following another specified type!\n"); if (Old) New = new LinearSpline(*Old); else New = new LinearSpline(); END_CASE CASE(QUADRATIC_SPLINE_TOKEN) splineTypeCount++; if (splineTypeCount > 1) Error("quadratic_spline following another specified type!\n"); if (Old) New = new QuadraticSpline(*Old); else New = new QuadraticSpline(); END_CASE CASE(CUBIC_SPLINE_TOKEN) splineTypeCount++; if (splineTypeCount > 1) Error("cubic_spline following another specified type!\n"); if (Old) New = new CatmullRomSpline(*Old); else New = new CatmullRomSpline(); END_CASE CASE(NATURAL_SPLINE_TOKEN) splineTypeCount++; if (splineTypeCount > 1) Error("natural_spline following another specified type!\n"); if (Old) New = new NaturalSpline(*Old); else New = new NaturalSpline(); END_CASE OTHERWISE UNGET EXIT END_CASE END_EXPECT if (!New) { if (Old) New = Old->Clone(); else New = new LinearSpline(); } if (Old && !keepOld) { delete Old; } EXPECT_CAT CASE_FLOAT_UNGET /* Entry has the form float,vector */ par = Parse_Float(); Parse_Comma(); Parse_Express(Express, &Terms); Promote_Express(Express,&Terms,2); if (Terms > 5) Error("Too many components in vector!\n"); MaxTerms = max(MaxTerms, Terms); Parse_Comma(); /* MWW 2000 -- Changed call for dynamic allocation version */ Insert_Spline_Entry(New, par, Express); i++; END_CASE OTHERWISE UNGET EXIT END_CASE END_EXPECT if (i < 1) Error("Spline without any entries. Or, referenced a non spline identifier."); New->Terms = MaxTerms; // keep number of supplied terms Allow_Identifier_In_Call = old_allow_id; return New; }