void CatmullRomSpline::Get(DBL p, EXPRESS& v) { if (SplineEntries.size() == 1) memcpy(&v, &SplineEntries.front().vec, sizeof(EXPRESS)); else { /* Find which spline segment we're in. i is the control point at the end of the segment */ SplineEntryList::size_type i = findt(this, p); for(int k=0; k<5; k++) { /* If only two points, return their average */ if(SplineEntries.size() == 2) v[k] = (SplineEntries[0].vec[k] + SplineEntries[1].vec[k])/2.0; /* Catmull-Rom: If only three points, return the second one */ else if(i < 2) v[k] = SplineEntries[1].vec[k]; /* Catmull-Rom: Can't interpolate before second point or after next-to-last */ else if(i >= SplineEntries.size()-1) v[k] = SplineEntries[SplineEntries.size()-2].vec[k]; /* Else, normal case */ else v[k] = catmull_rom_interpolate(SplineEntries, i-1, k, p); } } }
void QuadraticSpline::Get(DBL p, EXPRESS& v) { if (SplineEntries.size() == 1) memcpy(&v, &SplineEntries.front().vec, sizeof(EXPRESS)); else { /* Find which spline segment we're in. i is the control point at the end of the segment */ SplineEntryList::size_type i = findt(this, p); for(int k=0; k<5; k++) { /* If outside the spline range, return the first or last point */ if(i == 0) v[k] = SplineEntries.front().vec[k]; else if(i >= SplineEntries.size()) v[k] = SplineEntries.back().vec[k]; /* If not enough points, reduce order */ else if(SplineEntries.size() == 2) v[k] = linear_interpolate(SplineEntries, i-1, k, p); else { /* Normal case: between the second and last points */ if(i > 1) v[k] = quadratic_interpolate(SplineEntries, i-1, k, p); else /* Special case: between first and second points */ v[k] = quadratic_interpolate(SplineEntries, i, k, p); } } } }
void Insert_Spline_Entry(GenericSpline * sp, DBL p, const EXPRESS& v) { SplineEntryList::size_type i; int k; /* Reset the Coeffs_Computed flag. Inserting a new point invalidates * pre-computed coefficients */ sp->Coeffs_Computed = false; i = findt(sp, p); /* If p is already in spline, replace */ /* The clause after the || is needed because findt returns sp->SplineEntries.size() * if p is greater than OR EQUAL TO the highest par in the spline */ if(!sp->SplineEntries.empty() && ((sp->SplineEntries[i].par == p) || (i == sp->SplineEntries.size() && sp->SplineEntries[i-1].par == p))) { for(k=0; k<5; k++) sp->SplineEntries[i].vec[k] = v[k]; } else { mkfree(sp, i); sp->SplineEntries[i].par = p; for(k=0; k<5; k++) sp->SplineEntries[i].vec[k] = v[k]; } }
findt1(void) { int i; if (dip != d) i = dip->dnl; else i = numtabp[NL].val; return(findt(i)); }
TBool CAiwPrintingProvider::IsImagePrintUiRunning() { TFindThread findt(KImagePrintUiSearchPatternBySID); TFullName result; TBool running(EFalse); if (!findt.Next(result)) { FTRACE(FPrint(_L("[CAiwPrintingProvider] Thread '%S'is found"), &result)); running = ETrue; } return running; }
void eject(Stack *a) { int savlss; if (dip != d) return; ejf++; if (a) ejl = a; else ejl = frame; if (trap) return; e1: savlss = lss; lss = findt(numtabp[NL].val); newline(0); lss = savlss; if (numtabp[NL].val && !trap) goto e1; }
void LinearSpline::Get(DBL p, EXPRESS& v) { if (SplineEntries.size() == 1) memcpy(&v, &SplineEntries.front().vec, sizeof(EXPRESS)); else { /* Find which spline segment we're in. i is the control point at the end of the segment */ SplineEntryList::size_type i = findt(this, p); for(int k=0; k<5; k++) { /* If outside spline range, return first or last point */ if(i == 0) v[k] = SplineEntries.front().vec[k]; else if(i >= SplineEntries.size()) v[k] = SplineEntries.back().vec[k]; /* Else, normal case */ else v[k] = linear_interpolate(SplineEntries, i-1, k, p); } } }
void Insert_Spline_Entry(SPLINE * sp, DBL p, EXPRESS v) { int i, k; /* Reset the Coeffs_Computed flag. Inserting a new point invalidates * pre-computed coefficients */ sp->Coeffs_Computed = false; sp->Cache_Valid = false; /* If all space is used, reallocate */ if(sp->Number_Of_Entries >= sp->Max_Entries) { sp->Max_Entries += INIT_SPLINE_SIZE; sp->SplineEntries = (SPLINE_ENTRY *)POV_REALLOC(sp->SplineEntries, sp->Max_Entries * sizeof(SPLINE_ENTRY), "Temporary Spline Entries"); for (i = sp->Number_Of_Entries; i < sp->Max_Entries; i++) { sp->SplineEntries[i].par=-1e6; } } i = findt(sp, p); /* If p is already in spline, replace */ /* The clause after the || is needed because findt returns sp->Number_Of_Entries * if p is greater than OR EQUAL TO the highest par in the spline */ if(sp->Number_Of_Entries != 0 && ((sp->SplineEntries[i].par == p) || (i == sp->Number_Of_Entries && sp->SplineEntries[i-1].par == p))) { for(k=0; k<5; k++) sp->SplineEntries[i].vec[k] = v[k]; } else { mkfree(sp, i); sp->SplineEntries[i].par = p; for(k=0; k<5; k++) sp->SplineEntries[i].vec[k] = v[k]; sp->Number_Of_Entries += 1; } }
void NaturalSpline::Get(DBL p, EXPRESS& v) { if (SplineEntries.size() == 1) memcpy(&v, &SplineEntries.front().vec, sizeof(EXPRESS)); else { if (!Coeffs_Computed) Precompute_Cubic_Coeffs(this); /* Find which spline segment we're in. i is the control point at the end of the segment */ SplineEntryList::size_type i = findt(this, p); for(int k=0; k<5; k++) { /* If outside the spline range, return the first or last point */ if(i == 0) v[k] = SplineEntries.front().vec[k]; else if(i >= SplineEntries.size()) v[k] = SplineEntries.back().vec[k]; /* Else, normal case. cubic_interpolate can handle the case of not enough points */ else v[k] = natural_interpolate(SplineEntries, i-1, k, p); } } }
DBL Get_Spline_Val(SPLINE *sp, DBL p, EXPRESS v, int *Terms) { int i, k; int last; SPLINE_ENTRY * se; *Terms = sp->Terms; if(!sp->Coeffs_Computed) { switch(sp->Type) { case NATURAL_SPLINE: Precompute_Cubic_Coeffs(sp); break; default: break; } } // check if the value is in the cache if((sp->Cache_Point == p) && (sp->Cache_Type == sp->Type)) { if(sp->Cache_Valid == true) // doing this here is more efficient as it is rarely false [trf] { Assign_Express(v, sp->Cache_Data); return sp->Cache_Data[0]; } } // init some cache data sp->Cache_Valid = false; sp->Cache_Type = sp->Type; sp->Cache_Point = p; last = sp->Number_Of_Entries-1; se = sp->SplineEntries; if(last == 0) {/* if only one entry then return this */ for(k=0; k<5; k++) v[k] = se[0].vec[k]; return se[0].vec[0]; } /* Find which spline segment we're in. i is the control point at the end of the segment */ i = findt(sp, p); switch(sp->Type) { case LINEAR_SPLINE: for(k=0; k<5; k++) { /* If outside spline range, return first or last point */ if(i == 0) v[k] = se[0].vec[k]; else if(i > last) v[k] = se[last].vec[k]; /* Else, normal case */ else v[k] = linear_interpolate(se, i-1, k, p); } break; case QUADRATIC_SPLINE: for(k=0; k<5; k++) { /* If outside the spline range, return the first or last point */ if(i == 0) v[k] = se[0].vec[k]; else if(i > last) v[k] = se[last].vec[k]; /* If not enough points, reduce order */ else if(last == 1) v[k] = linear_interpolate(se, i-1, k, p); /* Normal case: between the second and last points */ else if(i > 1) { v[k] = quadratic_interpolate(se, i-1, k, p); } else /* Special case: between first and second points */ { v[k] = quadratic_interpolate(se, i, k, p); } } break; case NATURAL_SPLINE: for(k=0; k<5; k++) { /* If outside the spline range, return the first or last point */ if(i == 0) v[k] = se[0].vec[k]; else if(i > last) v[k] = se[last].vec[k]; /* Else, normal case. cubic_interpolate can handle the case of not enough points */ else v[k] = natural_interpolate(se, i-1, k, p); } break; case CATMULL_ROM_SPLINE: for(k=0; k<5; k++) { /* If only two points, return their average */ if(last == 1) v[k] = (se[0].vec[k] + se[1].vec[k])/2.0; /* Catmull-Rom: If only three points, return the second one */ /* Catmull-Rom: Can't interpolate before second point or after next-to-last */ else if(i < 2) v[k] = se[1].vec[k]; else if(i >= last) v[k] = se[last-1].vec[k]; /* Else, normal case */ else v[k] = catmull_rom_interpolate(se, i-1, k, p); } break; default: Error("Unknown spline type %d found.\n", sp->Type); } // put data in cache Assign_Express(sp->Cache_Data, v); sp->Cache_Valid = true; return v[0]; }
void newline(int a) { int i, j, nlss; int opn; nlss = 0; if (a) goto nl1; if (dip != d) { j = lss; pchar1((Tchar)FLSS); if (flss) lss = flss; i = lss + dip->blss; dip->dnl += i; pchar1((Tchar)i); pchar1((Tchar)'\n'); lss = j; dip->blss = flss = 0; if (dip->alss) { pchar1((Tchar)FLSS); pchar1((Tchar)dip->alss); pchar1((Tchar)'\n'); dip->dnl += dip->alss; dip->alss = 0; } if (dip->ditrap && !dip->ditf && dip->dnl >= dip->ditrap && dip->dimac) if (control(dip->dimac, 0)) { trap++; dip->ditf++; } return; } j = lss; if (flss) lss = flss; nlss = dip->alss + dip->blss + lss; numtabp[NL].val += nlss; if (TROFF && ascii) { dip->alss = dip->blss = 0; } pchar1((Tchar)'\n'); flss = 0; lss = j; if (numtabp[NL].val < pl) goto nl2; nl1: ejf = dip->hnl = numtabp[NL].val = 0; ejl = frame; if (donef) { if ((!nc && !wch) || ndone) done1(0); ndone++; donef = 0; if (frame == stk) nflush++; } opn = numtabp[PN].val; numtabp[PN].val++; if (npnflg) { numtabp[PN].val = npn; npn = npnflg = 0; } nlpn: if (numtabp[PN].val == pfrom) { print++; pfrom = -1; } else if (opn == pto) { print = 0; opn = -1; chkpn(); goto nlpn; } if (print) ptpage(numtabp[PN].val); /* supposedly in a clean state so can pause */ if (stop && print) { dpn++; if (dpn >= stop) { dpn = 0; ptpause(); } } nl2: trap = 0; if (numtabp[NL].val == 0) { if ((j = findn(0)) != NTRAP) trap = control(mlist[j], 0); } else if ((i = findt(numtabp[NL].val - nlss)) <= nlss) { if ((j = findn1(numtabp[NL].val - nlss + i)) == NTRAP) { flusho(); ERROR "Trap botch." WARN; done2(-5); } trap = control(mlist[j], 0); } }