public Contour ContByKnot(Knot knot) { foreach (Contour cont in this.conts) { if (cont.PozByKnot(knot)!=GConsts.POZ_INVALID) { return cont; } } return null; }
public Contour(Contour cont): this() { if (cont==null) { throw new ExceptionGMath("Contour","Contour","Null argument"); } Knot knCopy; foreach (Knot kn in cont.knots) { knCopy=new Knot(kn); this.knots.Add(knCopy); } }
public void ParamToCParam(Knot kn0, Knot kn1) { this.param[0]=new CParam(this.param[0], kn0); if (this.param[1]!=null) { this.param[1]=new CParam(this.param[1], kn1); } }
override public void ParamToCParam(Knot kn0, Knot kn1) { this.ipis[0].ParamToCParam(kn0,kn1); this.ipis[1].ParamToCParam(kn0,kn1); }
virtual public void ParamToCParam(Knot kn0, Knot kn1) { throw new ExceptionGMath("InfoInters","ParamToCParam","Pure virtual function"); }
/* * CONSTRUCTORS */ public CParam(double val, Knot knot) { this.Val = val; this.knot = knot; }
public BCurve CurveByKnot(Knot knot) { int poz=this.PozByKnot(knot); return (this.CurveByPoz(poz)); }
public void KnotAdd(Knot knot) { // TODO: check !!! this.knots.Add(knot); }
public void ReadGGO(int indexGlyph, out Outline outl, DIAction dia) { this.m_validator.DIA=dia; outl=null; GConsts.TypeGlyph typeGlyph; this.ReadTypeGlyph(indexGlyph, out typeGlyph, dia); if (typeGlyph!=GConsts.TypeGlyph.Simple) return; int offsStart, length; if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph, out offsStart, out length, this.m_validator, this.m_font)) return; MBOBuffer buffer=this.m_tableGlyf.Buffer; int iKnot; ushort[] arrIndKnotEnd; short[] arrXRel, arrYRel; byte[] arrFlag; int numCont; try { numCont=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.numCont)); arrIndKnotEnd = new ushort [numCont]; for (short iCont=0; iCont<numCont; iCont++) { arrIndKnotEnd[iCont]=buffer.GetUshort((uint)(offsStart+Table_glyf.FieldOffsets.nextAfterHeader+iCont*2)); } int numKnot=arrIndKnotEnd[numCont-1]+1; uint offsInstrLength=(uint)(offsStart+Table_glyf.FieldOffsets.nextAfterHeader+2*numCont); ushort lengthInstr=buffer.GetUshort(offsInstrLength); uint offsInstr=offsInstrLength+2; uint offsFlag=offsInstr+lengthInstr; arrFlag = new byte [numKnot]; iKnot=0; // index of flag in array flags uint offsCur=offsFlag; // counter of flag in the file while (iKnot<numKnot) { byte flag=buffer.GetByte(offsCur++); arrFlag[iKnot++]=flag; bool toRepeat=((flag&(byte)(Table_glyf.MaskFlagKnot.toRepeat))!=0); if (toRepeat) { byte numRepeat=buffer.GetByte(offsCur++); for (byte iRepeat=0; iRepeat<numRepeat; iRepeat++) { arrFlag[iKnot++]=flag; } } } arrXRel = new short [numKnot]; arrYRel = new short [numKnot]; // read data for x-coordinates for (iKnot=0; iKnot<numKnot; iKnot++) { if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isXByte))!=0) { byte xRel=buffer.GetByte(offsCur++); if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isXSameOrPozitive))!=0) { arrXRel[iKnot]=xRel; } else { arrXRel[iKnot]=(short)(-xRel); } } else { if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isXSameOrPozitive))!=0) { arrXRel[iKnot]=0; } else { arrXRel[iKnot]=buffer.GetShort(offsCur); offsCur+=2; } } } // read data for y-coordinates for (iKnot=0; iKnot<numKnot; iKnot++) { if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isYByte))!=0) { byte yRel=buffer.GetByte(offsCur++); if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isYSameOrPozitive))!=0) { arrYRel[iKnot]=yRel; } else { arrYRel[iKnot]=(short)(-yRel); } } else { if ((arrFlag[iKnot]&(byte)(Table_glyf.MaskFlagKnot.isYSameOrPozitive))!=0) { arrYRel[iKnot]=0; } else { arrYRel[iKnot]=buffer.GetShort(offsCur); offsCur+=2; } } } if (offsCur-2>=offsStart+length) { throw new System.IndexOutOfRangeException(); } } catch (System.IndexOutOfRangeException) { this.m_validator.Error( E._GEN_E_OffsetExceedsTableLength, (OTTag)"glyf"); return; } try { short xAbs=0; short yAbs=0; int indKnotStart, indKnotEnd=-1; outl=new Outline(); for (ushort iCont=0; iCont<numCont; iCont++) { indKnotStart=indKnotEnd+1; indKnotEnd=arrIndKnotEnd[iCont]; Contour cont=null; cont = new Contour(); for (iKnot=indKnotStart; iKnot<=indKnotEnd; iKnot++) { xAbs += arrXRel[iKnot]; yAbs += arrYRel[iKnot]; bool isOn=((arrFlag[iKnot]&((byte)(Table_glyf.MaskFlagKnot.isOnCurve)))!=0); Knot knot = new Knot(iKnot, xAbs, yAbs, isOn); cont.KnotAdd(knot); } outl.ContourAdd(cont); } } catch { outl.ClearDestroy(); outl=null; } }
/* * METHODS: INFO (all information is copied * prior passing to a user) */ public Knot InfoKnotByLocation(VecD vecLocation) { Knot knotNearestCopy=null; if (this.outl!=null) { Knot knotNearest=this.outl.KnotNearest(vecLocation); if (knotNearest!=null) { knotNearestCopy=new Knot(knotNearest); } } return knotNearestCopy; }
public bool RayParity(RayD ray, CParam parStartRay, out MConsts.TypeParity typeParity) { /* * ASSUMPTIONS * INPUT: * - (parStartRay==null) is the ray does not start at * the contour * RETURN VALUE; * - (false) in case of real failure; * (true)+(typeParity==Undef) in unclear cases * */ typeParity = MConsts.TypeParity.Undef; ListInfoInters linters = new ListInfoInters(); bool isStartIntersFound = false; for (int pozKnot = 0; pozKnot < this.NumKnot; pozKnot++) { BCurve curve = this.CurveByPoz(pozKnot); if (curve != null) { Knot knot = this.KnotByPoz(pozKnot); int numIntersBefore = linters.Count; if (!Inters.IntersectBL(curve, ray, linters)) { linters.ClearDestroy(); return(false); } int numIntersAfter = linters.Count; if (numIntersAfter != numIntersBefore) { InfoInters inters; if ((curve.IsDegen) || (curve.IsSelfInters(out inters))) { linters.ClearDestroy(); return(true); } } bool isRayStartOnCurve = ((parStartRay != null) && (parStartRay.IndKnot == knot.IndexKnot)); for (int iInters = numIntersBefore; iInters < numIntersAfter; iInters++) { InfoInters inters = linters[iInters] as InfoInters; if (inters.Dim == InfoInters.TypeDim.Dim1) { linters.ClearDestroy(); return(true); } IntersD0 intersD0 = inters as IntersD0; double parValCurve = intersD0.Ipi.Par(0).Val; double parValRay = intersD0.Ipi.Par(1).Val; if (Math.Abs(parValRay) < MConsts.EPS_DEC) { if ((!isRayStartOnCurve) || (isRayStartOnCurve && isStartIntersFound)) { linters.ClearDestroy(); return(true); } isStartIntersFound = true; } if ((Math.Abs(parValCurve) < MConsts.EPS_DEC_WEAK) || (Math.Abs(1.0 - parValCurve) < MConsts.EPS_DEC_WEAK)) { linters.ClearDestroy(); return(true); } VecD dirTangCurve = curve.DirTang(parValCurve); VecD dirTangRay = (ray as LCurve).DirTang; if ((dirTangCurve == null) || (dirTangRay == null)) { linters.ClearDestroy(); return(true); } if (Math.Abs(dirTangRay.Cross(dirTangCurve)) < MConsts.EPS_DEC_WEAK) { linters.ClearDestroy(); return(true); } } if ((isRayStartOnCurve) && (!isStartIntersFound)) { linters.ClearDestroy(); return(true); } } } int numIntersAll = (isStartIntersFound)? linters.Count - 1: linters.Count; typeParity = (numIntersAll % 2 == 0)? MConsts.TypeParity.Even: MConsts.TypeParity.Odd; linters.ClearDestroy(); return(true); }
public BCurve CurveByKnot(Knot knot) { int poz = this.PozByKnot(knot); return(this.CurveByPoz(poz)); }
/* * METHODS */ override public void ClearRelease() { this.knot = null; }
public void KnotDelete(Knot knot) { Contour cont=this.ContByKnot(knot); if (cont!=null) { cont.KnotDelete(knot); if (cont.NumKnot==0) { this.ContourDelete(cont); } } this.ReNumber(); }
public BCurve CurveByKnot(Knot knot) { Contour cont=this.ContByKnot(knot); if (cont==null) return null; return (cont.CurveByKnot(knot)); }
public void ParamToCParam(Knot kn0, Knot kn1, int pozStart) { for (int poz=pozStart; poz<this.linters.Count; poz++) { InfoInters inters=linters[poz] as InfoInters; inters.ParamToCParam(kn0,kn1); } }
public int PozByKnot(Knot knot) { for (int poz=0; poz<this.knots.Count; poz++) { if ((object)this.knots[poz]==(object)knot) { return poz; } } return GConsts.POZ_INVALID; //return (this.knots.IndexOf((object)knot)); }
/* * CONSTRUCTORS */ public CParam(double val, Knot knot) { this.Val=val; this.knot=knot; }
public void KnotDelete(Knot knot) { if (this.knots.Contains(knot)) { this.knots.Remove(knot); } }
public CParam(Param par, Knot knot) { if (par.GetType()!=typeof(Param)) { throw new ExceptionGMath("Param","CParam",null); } this.Val=par.Val; this.knot=knot; }
/* * METHODS */ override public void ClearRelease() { this.knot=null; }
public Knot(Knot knot): this(knot.IndexKnot,knot.Val,knot.On) { }