/* * METHODS : VALIDATORS CONTENT * */ internal StatusGV.TypeStatusExec ValidateSimpBBox(GErrList gerrlist) { if ((this.bbox == null) || (this.outl == null)) { //throw new ExceptionGlyph("Glyph","ValidateSimpBBox",null); return(StatusGV.TypeStatusExec.Aborted); } BoxD bboxCP; // bbox for the control points bboxCP = this.outl.BBoxCP; if (!bbox.Equals(bboxCP)) { GErrBBox gerrBbox = new GErrBBox(this.IndexGlyph, this.typeGlyph, this.bbox, bboxCP); gerrlist.Add(gerrBbox); } BoxD bboxOutl; // bbox for Outline bboxOutl = this.outl.BBox; //bboxOutline.SetEnlargeFU(); if (!bboxOutl.Equals(bboxCP)) { // warning GErrExtremeNotOnCurve gerrExtreme = new GErrExtremeNotOnCurve(this.IndexGlyph, this.typeGlyph, bboxCP, bboxOutl); gerrlist.Add(gerrExtreme); } return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateCompComponentDupl(GErrList gerrlist) { ListPairInt pairsIndComponentDupl = new ListPairInt(); if ((this.comp == null) || (this.outl == null)) { //throw new ExceptionGlyph("Glyph","ValidateCompComponentDupl",null); return(StatusGV.TypeStatusExec.Aborted); } int numComponent = this.comp.NumComponent; for (int pozComponentA = 0; pozComponentA < numComponent - 1; pozComponentA++) { Component componentA = this.comp.ComponentByPoz(pozComponentA); for (int pozComponentB = pozComponentA + 1; pozComponentB < numComponent; pozComponentB++) { ListInfoInters linters = new ListInfoInters(); Component componentB = this.comp.ComponentByPoz(pozComponentB); bool areDuplicated; this.outl.AreDuplicatedComponents(componentA, componentB, out areDuplicated); if (areDuplicated) { pairsIndComponentDupl.Add(componentA.IndexGlyphComponent, componentB.IndexGlyphComponent); } } } if (pairsIndComponentDupl.Count != 0) { GErr gerr = new GErrComponentDupl(this.index, pairsIndComponentDupl); gerrlist.Add(gerr); } return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateSimpContDegen(GErrList gerrlist) { ArrayList listIndsKnotStart = new ArrayList(); for (int pozCont = 0; pozCont < this.outl.NumCont; pozCont++) { Contour cont = this.outl.ContourByPoz(pozCont); if (cont.IsDegen) { listIndsKnotStart.Add(cont.IndKnotStart); } } int numCont = listIndsKnotStart.Count; if (numCont != 0) { int[] indsKnotStart = new int[numCont]; for (int iCont = 0; iCont < numCont; iCont++) { indsKnotStart[iCont] = (int)listIndsKnotStart[iCont]; } GErr gerr = new GErrContDegen(this.index, indsKnotStart); gerrlist.Add(gerr); } return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateSimpContInters(GErrList gerrlist) { /* * MEANING: finds ALL intersections: * including D0, D1 and S/I bezier */ ListInfoInters linters = new ListInfoInters(); if (this.outl == null) { //throw new ExceptionGlyph("Glyph","ValidateSimpContInters",null); return(StatusGV.TypeStatusExec.Aborted); } if (!this.outl.Intersect(linters)) { //throw new ExceptionGlyph("Glyph","ValidateSimpContInters",null); return(StatusGV.TypeStatusExec.Aborted); } if (linters.Count > 0) { GErr gerr = new GErrContInters(this.index, linters); gerrlist.Add(gerr); //this.isOrientDefined=false; } return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateSimpContWrap(GErrList gerrlist) { /* * ASSUMPTION: determines only "fully" wrapped contours */ if (this.outl == null) { //throw new ExceptionGlyph("Glyph","ValidateSimpContWrap",null); return(StatusGV.TypeStatusExec.Aborted); } ArrayList pozsContWrap = new ArrayList(); for (int pozCont = 0; pozCont < this.outl.NumCont; pozCont++) { Contour cont = this.outl.ContourByPoz(pozCont); bool isWrapped; if (!cont.IsWrapped(out isWrapped)) { //throw new ExceptionGlyph("Glyph","ValidateSimpContWrap",null); return(StatusGV.TypeStatusExec.Aborted); } if (isWrapped) { pozsContWrap.Add(pozCont); } } int numCont = pozsContWrap.Count; if (numCont != 0) { int[] indsKnotStart = new int[numCont]; for (int iCont = 0; iCont < numCont; iCont++) { int pozCont = (int)pozsContWrap[iCont]; indsKnotStart[iCont] = this.Outl.ContourByPoz(pozCont).IndKnotStart; } GErr gerr = new GErrContWrap(this.index, indsKnotStart); gerrlist.Add(gerr); //this.isOrientDefined=false; } /* * else * { * //this.isOrientDefined=true; * } */ pozsContWrap.Clear(); return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateCompBBox(GErrList gerrlist) { if ((this.bbox == null) || (this.outl == null)) { //throw new ExceptionGlyph("Glyph","ValidateCompBBox",null); return(StatusGV.TypeStatusExec.Aborted); } BoxD bboxCP; // bbox for the control points bboxCP = this.outl.BBoxCP; if (!this.bbox.Equals(bboxCP)) { double deviation = this.bbox.DeviationMax(bboxCP); bool toSkipError = ((this.outl.IsChangedByRound) && (Math.Abs(deviation) <= 1.0)); if (!toSkipError) { GErrBBox gerrBbox = new GErrBBox(this.IndexGlyph, this.typeGlyph, this.bbox, bboxCP); gerrlist.Add(gerrBbox); } } BoxD bboxOutl; // bbox for Outline bboxOutl = this.outl.BBox; //bboxOutline.SetEnlargeFU(); if (!bboxOutl.Equals(bboxCP)) { // warning GErrExtremeNotOnCurve gerrExtreme = new GErrExtremeNotOnCurve(this.IndexGlyph, this.typeGlyph, bboxCP, bboxOutl); gerrlist.Add(gerrExtreme); } return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateSimpContMisor(GErrList gerrlist) { if ((this.statusGV[(int)DefsGV.TypeGV.ValidateSimpContDupl].StatusRes != StatusGV.TypeStatusRes.NoErrors) || (this.statusGV[(int)DefsGV.TypeGV.ValidateSimpContWrap].StatusRes != StatusGV.TypeStatusRes.NoErrors) || (this.statusGV[(int)DefsGV.TypeGV.ValidateSimpContInters].StatusRes != StatusGV.TypeStatusRes.NoErrors)) { return(StatusGV.TypeStatusExec.UnableToExec); } if (this.outl == null) { //throw new ExceptionGlyph("Glyph","ValidateSimpContMisor",null); return(StatusGV.TypeStatusExec.Aborted); } ArrayList pozsContMisor = new ArrayList(); for (int pozCont = 0; pozCont < this.outl.NumCont; pozCont++) { Contour cont = this.outl.ContourByPoz(pozCont); bool isMisoriented; if (!cont.IsMisoriented(this.outl, out isMisoriented)) { throw new ExceptionGlyph("Glyph", "ValidateSimpContMisor", null); //return StatusGV.TypeStatusExec.Aborted; } if (isMisoriented) { pozsContMisor.Add(pozCont); } } int numCont = pozsContMisor.Count; if (numCont != 0) { int[] indsKnotStart = new int[numCont]; for (int iCont = 0; iCont < numCont; iCont++) { int pozCont = (int)pozsContMisor[iCont]; indsKnotStart[iCont] = this.Outl.ContourByPoz(pozCont).IndKnotStart; } GErr gerr = new GErrContMisor(this.index, indsKnotStart); gerrlist.Add(gerr); } pozsContMisor.Clear(); return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateSimpKnotDupl(GErrList gerrlist) { ListPairInt infosKnotDupl = new ListPairInt(); for (int pozCont = 0; pozCont < this.outl.NumCont; pozCont++) { Contour cont = this.outl.ContourByPoz(pozCont); cont.KnotDupl(infosKnotDupl); } if (infosKnotDupl.Count != 0) { GErr gerr = new GErrKnotDupl(this.index, infosKnotDupl); gerrlist.Add(gerr); } return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateCompComponentInters(GErrList gerrlist) { ArrayList arrLinters = new ArrayList(); if ((this.comp == null) || (this.outl == null)) { //throw new ExceptionGlyph("Glyph","ValidateCompComponentInters",null); return(StatusGV.TypeStatusExec.Aborted); } int numComponent = this.comp.NumComponent; for (int pozComponentA = 0; pozComponentA < numComponent - 1; pozComponentA++) { Component componentA = this.comp.ComponentByPoz(pozComponentA); for (int pozComponentB = pozComponentA + 1; pozComponentB < numComponent; pozComponentB++) { ListInfoInters linters = new ListInfoInters(); Component componentB = this.comp.ComponentByPoz(pozComponentB); bool areDuplicated; this.outl.AreDuplicatedComponents(componentA, componentB, out areDuplicated); if (areDuplicated) { continue; } this.outl.IntersectComponents(componentA, componentB, linters); if (linters.Count != 0) { linters.SetIndGlyphComponent(componentA.IndexGlyphComponent, componentB.IndexGlyphComponent); arrLinters.Add(linters); } } } if (arrLinters.Count != 0) { GErr gerr = new GErrComponentInters(this.index, arrLinters); gerrlist.Add(gerr); } return(StatusGV.TypeStatusExec.Completed); }
// return value: whether the list contains at least one "true" item public bool FilterByCond(DICond dic, GErrList gerrlist) { if (dic == null) { throw new ExceptionGlyph("GErrList", "FilterByCondition", "Null argument"); } bool res = false; foreach (GErr gerr in this.gerrs) { if (dic(gerr)) { if (gerrlist != null) { gerrlist.Add(gerr); res = true; } } } return(res); }
internal StatusGV.TypeStatusExec ValidateSimpContDupl(GErrList gerrlist) { if (this.outl == null) { //throw new ExceptionGlyph("Glyph","ValidateSimpContDupl",null); return(StatusGV.TypeStatusExec.Aborted); } ListPairInt pairsIndKnotStart = new ListPairInt(); for (int pozContA = 0; pozContA < this.outl.NumCont - 1; pozContA++) { Contour contA = this.outl.ContourByPoz(pozContA); for (int pozContB = pozContA + 1; pozContB < this.outl.NumCont; pozContB++) { Contour contB = this.outl.ContourByPoz(pozContB); bool isDupl; if (!contA.AreDuplicated(contB, out isDupl)) { //throw new ExceptionGlyph("Glyph","ValidateSimpContDupl",null); return(StatusGV.TypeStatusExec.Aborted); } if (isDupl) { pairsIndKnotStart.Add(this.outl.ContourByPoz(pozContA).IndKnotStart, this.outl.ContourByPoz(pozContB).IndKnotStart); } } } if (pairsIndKnotStart.Count != 0) { GErr gerr = new GErrContDupl(this.index, pairsIndKnotStart); gerrlist.Add(gerr); //this.isOrientDefined=false; } return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateCompBBox(GErrList gerrlist) { if ((this.bbox==null)||(this.outl==null)) { //throw new ExceptionGlyph("Glyph","ValidateCompBBox",null); return StatusGV.TypeStatusExec.Aborted; } BoxD bboxCP; // bbox for the control points bboxCP=this.outl.BBoxCP; if (!this.bbox.Equals(bboxCP)) { double deviation=this.bbox.DeviationMax(bboxCP); bool toSkipError=((this.outl.IsChangedByRound)&&(Math.Abs(deviation)<=1.0)); if (!toSkipError) { GErrBBox gerrBbox=new GErrBBox(this.IndexGlyph, this.typeGlyph, this.bbox,bboxCP); gerrlist.Add(gerrBbox); } } BoxD bboxOutl; // bbox for Outline bboxOutl=this.outl.BBox; //bboxOutline.SetEnlargeFU(); if (!bboxOutl.Equals(bboxCP)) { // warning GErrExtremeNotOnCurve gerrExtreme=new GErrExtremeNotOnCurve(this.IndexGlyph, this.typeGlyph,bboxCP,bboxOutl); gerrlist.Add(gerrExtreme); } return StatusGV.TypeStatusExec.Completed; }
// return value: whether the list contains at least one "true" item public bool FilterByCond(DICond dic, GErrList gerrlist) { if (dic==null) { throw new ExceptionGlyph("GErrList","FilterByCondition","Null argument"); } bool res=false; foreach (GErr gerr in this.gerrs) { if (dic(gerr)) { if (gerrlist!=null) { gerrlist.Add(gerr); res=true; } } } return res; }
internal StatusGV.TypeStatusExec ValidateCompBind(GErrList gerrlist) { /* * ASSUMPTION: - the glyph is composite and Comp is already * read * - clears outline that is already * built in case of failure to load one * of components */ if (this.outl != null) { this.outl.ClearDestroy(); this.outl = null; } GErr gerr; bool isCircular = this.fm.PathCompBind.Contains(this.index); if (isCircular) { int numGlyph = this.fm.PathCompBind.Count; int[] pathCompBind = new int[numGlyph + 1]; for (int iGlyph = 0; iGlyph < numGlyph; iGlyph++) { pathCompBind[iGlyph] = (int)this.fm.PathCompBind[iGlyph]; } pathCompBind[numGlyph] = this.index; gerr = new GErrComponentCircularDependency(this.index, this.index, pathCompBind); gerrlist.Add(gerr); this.fm.PathCompBind.Clear(); return(StatusGV.TypeStatusExec.Completed); } if (this.outl != null) { this.outl.ClearReset(); this.outl = null; } if (this.comp == null) { //throw new ExceptionGlyph("Glyph","ValidateCompBind",null); return(StatusGV.TypeStatusExec.Aborted); } this.fm.PathCompBind.Add(this.index); //throw new ArgumentOutOfRangeException(); if (this.comp.NumComponent == 0) { this.outl = new Outline(); gerr = new GErrComponentEmpty(this.index, GConsts.IND_UNDEFINED); gerrlist.Add(gerr); return(StatusGV.TypeStatusExec.Completed); } foreach (Component component in this.comp) { int indGlyphComponent = component.IndexGlyphComponent; if ((indGlyphComponent < 0) || (indGlyphComponent >= this.fm.FNumGlyph)) { gerr = new GErrComponentIndexGlyph(this.index, indGlyphComponent); gerrlist.Add(gerr); this.fm.PathCompBind.Clear(); if (this.outl != null) { this.outl.ClearDestroy(); this.outl = null; } return(StatusGV.TypeStatusExec.Completed); } Glyph glyphComponent = this.fm.GGet(indGlyphComponent); if (glyphComponent == null) { gerr = new GErrComponentLoadFailure(this.index, indGlyphComponent); gerrlist.Add(gerr); this.fm.PathCompBind.Clear(); if (this.outl != null) { this.outl.ClearDestroy(); this.outl = null; } return(StatusGV.TypeStatusExec.Completed); } if (glyphComponent.typeGlyph == GConsts.TypeGlyph.Empty) { gerr = new GErrComponentEmpty(this.index, indGlyphComponent); gerrlist.Add(gerr); continue; } else { if (glyphComponent.Outl == null) { gerr = new GErrComponentLoadFailure(this.index, indGlyphComponent); gerrlist.Add(gerr); this.fm.PathCompBind.Clear(); if (this.outl != null) { this.outl.ClearDestroy(); this.outl = null; } return(StatusGV.TypeStatusExec.Completed); } } if (this.outl == null) { this.outl = new Outline(); } ArrayList errsLoadComponent; if (!this.outl.LoadComponent(component, glyphComponent.outl, out errsLoadComponent)) { this.fm.PathCompBind.Clear(); if (this.outl != null) { this.outl.ClearDestroy(); this.outl = null; } //throw new ExceptionGlyph("Glyph","ValidateCompBind",null); return(StatusGV.TypeStatusExec.Aborted); } if (errsLoadComponent != null) { foreach (Component.TypeErrLoadComponent errLoadComponent in errsLoadComponent) { gerr = null; switch (errLoadComponent) { case Component.TypeErrLoadComponent.IncorrectShiftSpecification: gerr = new GErrComponentIncorrectShift(this.index, component.IndexGlyphComponent); break; case Component.TypeErrLoadComponent.IncorrectIndexKnotGlyph: gerr = new GErrComponentIndexKnot(this.index, component.IndexGlyphComponent, component.IndexKnotAttGlyph, true); break; case Component.TypeErrLoadComponent.IncorrectIndexKnotComponent: gerr = new GErrComponentIndexKnot(this.index, component.IndexGlyphComponent, component.IndexKnotAttComponent, false); break; case Component.TypeErrLoadComponent.IncorrectTransform: gerr = new GErrComponentIncorrectTransform(this.index, component.IndexGlyphComponent, component.TrOTF2Dot14); break; } gerrlist.Add(gerr); } if (this.outl != null) { this.outl.ClearDestroy(); this.outl = null; } this.fm.PathCompBind.Clear(); return(StatusGV.TypeStatusExec.Completed); } } this.fm.PathCompBind.RemoveAt(this.fm.PathCompBind.Count - 1); return(StatusGV.TypeStatusExec.Completed); }
internal StatusGV.TypeStatusExec ValidateCompComponentInters(GErrList gerrlist) { ArrayList arrLinters=new ArrayList(); if ((this.comp==null)||(this.outl==null)) { //throw new ExceptionGlyph("Glyph","ValidateCompComponentInters",null); return StatusGV.TypeStatusExec.Aborted; } int numComponent=this.comp.NumComponent; for (int pozComponentA=0; pozComponentA<numComponent-1; pozComponentA++) { Component componentA=this.comp.ComponentByPoz(pozComponentA); for (int pozComponentB=pozComponentA+1; pozComponentB<numComponent; pozComponentB++) { ListInfoInters linters=new ListInfoInters(); Component componentB=this.comp.ComponentByPoz(pozComponentB); bool areDuplicated; this.outl.AreDuplicatedComponents(componentA,componentB,out areDuplicated); if (areDuplicated) continue; this.outl.IntersectComponents(componentA, componentB, linters); if (linters.Count!=0) { linters.SetIndGlyphComponent(componentA.IndexGlyphComponent, componentB.IndexGlyphComponent); arrLinters.Add(linters); } } } if (arrLinters.Count!=0) { GErr gerr=new GErrComponentInters(this.index, arrLinters); gerrlist.Add(gerr); } return StatusGV.TypeStatusExec.Completed; }
/* * METHODS : VALIDATORS CONTENT * */ internal StatusGV.TypeStatusExec ValidateSimpBBox(GErrList gerrlist) { if ((this.bbox==null)||(this.outl==null)) { //throw new ExceptionGlyph("Glyph","ValidateSimpBBox",null); return StatusGV.TypeStatusExec.Aborted; } BoxD bboxCP; // bbox for the control points bboxCP=this.outl.BBoxCP; if (!bbox.Equals(bboxCP)) { GErrBBox gerrBbox=new GErrBBox(this.IndexGlyph, this.typeGlyph, this.bbox,bboxCP); gerrlist.Add(gerrBbox); } BoxD bboxOutl; // bbox for Outline bboxOutl=this.outl.BBox; //bboxOutline.SetEnlargeFU(); if (!bboxOutl.Equals(bboxCP)) { // warning GErrExtremeNotOnCurve gerrExtreme=new GErrExtremeNotOnCurve(this.IndexGlyph, this.typeGlyph,bboxCP,bboxOutl); gerrlist.Add(gerrExtreme); } return StatusGV.TypeStatusExec.Completed; }
private void CallGV(DefsGV.TypeGV typeGV) { /* * TRY/CATCH function */ /* * MEANING: UNCONDITIONAL call of action */ GErrList gerrlist=null; try { this.statusGV[(int)typeGV].StatusExec=StatusGV.TypeStatusExec.Aborted; this.statusGV[(int)typeGV].StatusRes=StatusGV.TypeStatusRes.Undef; gerrlist=new GErrList(); if (DefsGV.IsModifier(typeGV)) { this.fm.OnGM(this.index,DefsGM.From(typeGV),true); } // check that pre-required tests are performed if (!this.CanBeExec(typeGV)) { this.statusGV[(int)typeGV].StatusExec= StatusGV.TypeStatusExec.UnableToExec; } // call Validate.. function System.Exception excValidation=null; if (this.statusGV[(int)typeGV].StatusExec!= StatusGV.TypeStatusExec.UnableToExec) { try { string strTypeCV=Enum.GetName(typeof(DefsGV.TypeGV),typeGV); MethodInfo infoMethod=this.GetType().GetMethod(strTypeCV, System.Reflection.BindingFlags.Instance| System.Reflection.BindingFlags.NonPublic); if (infoMethod!=null) { object[] pars={gerrlist}; // statusGV can be set to: // Completed || UnableToExec || Aborted try { this.statusGV[(int)typeGV].StatusExec=(StatusGV.TypeStatusExec) infoMethod.Invoke(this, pars); } catch(System.Reflection.TargetInvocationException TIException) { throw TIException.InnerException; } GErrSign.Sign(gerrlist, typeGV, this.index); } if (this.statusGV[(int)typeGV].StatusExec== StatusGV.TypeStatusExec.Completed) { this.statusGV[(int)typeGV].StatusRes= gerrlist.StatusResGV(typeGV); } } catch (System.Exception exc) { excValidation=exc; this.statusGV[(int)typeGV].StatusExec= StatusGV.TypeStatusExec.Aborted; } } if (this.statusGV[(int)typeGV].StatusExec!= StatusGV.TypeStatusExec.Completed) { this.CleanUpOnNonCompletedGV(typeGV); GErrValidation gerrVal=new GErrValidation(this.index, this.typeGlyph, typeGV, this.statusGV[(int)typeGV].StatusExec, excValidation); gerrlist.Add(gerrVal); } GErrSign.Sign(gerrlist,typeGV,this.index); this.fm.OnGV(this.index, typeGV, gerrlist); gerrlist.ClearRelease(); } catch (Exception excManagement) // exception thrown by the fm management structures { this.statusGV[(int)typeGV].StatusExec= StatusGV.TypeStatusExec.Aborted; this.CleanUpOnNonCompletedGV(typeGV); // T/C function GErrValidation gerrVal=new GErrValidation(this.index, this.typeGlyph, typeGV, StatusGV.TypeStatusExec.Aborted, excManagement); this.fm.ReportFailure(gerrVal); // T/C function if (gerrlist!=null) { try { gerrlist.ClearRelease(); } catch (Exception) {} } } }
internal StatusGV.TypeStatusExec ValidateSimpContDegen(GErrList gerrlist) { ArrayList listIndsKnotStart=new ArrayList(); for (int pozCont=0; pozCont<this.outl.NumCont; pozCont++) { Contour cont=this.outl.ContourByPoz(pozCont); if (cont.IsDegen) { listIndsKnotStart.Add(cont.IndKnotStart); } } int numCont=listIndsKnotStart.Count; if (numCont!=0) { int[] indsKnotStart=new int[numCont]; for (int iCont=0; iCont<numCont; iCont++) { indsKnotStart[iCont]=(int)listIndsKnotStart[iCont]; } GErr gerr=new GErrContDegen(this.index, indsKnotStart); gerrlist.Add(gerr); } return StatusGV.TypeStatusExec.Completed; }
internal StatusGV.TypeStatusExec ValidateSimpKnotDupl(GErrList gerrlist) { ListPairInt infosKnotDupl=new ListPairInt(); for (int pozCont=0; pozCont<this.outl.NumCont; pozCont++) { Contour cont=this.outl.ContourByPoz(pozCont); cont.KnotDupl(infosKnotDupl); } if (infosKnotDupl.Count!=0) { GErr gerr=new GErrKnotDupl(this.index, infosKnotDupl); gerrlist.Add(gerr); } return StatusGV.TypeStatusExec.Completed; }
internal StatusGV.TypeStatusExec ValidateSimpContWrap(GErrList gerrlist) { /* * ASSUMPTION: determines only "fully" wrapped contours */ if (this.outl==null) { //throw new ExceptionGlyph("Glyph","ValidateSimpContWrap",null); return StatusGV.TypeStatusExec.Aborted; } ArrayList pozsContWrap=new ArrayList(); for (int pozCont=0; pozCont<this.outl.NumCont; pozCont++) { Contour cont=this.outl.ContourByPoz(pozCont); bool isWrapped; if (!cont.IsWrapped(out isWrapped)) { //throw new ExceptionGlyph("Glyph","ValidateSimpContWrap",null); return StatusGV.TypeStatusExec.Aborted; } if (isWrapped) { pozsContWrap.Add(pozCont); } } int numCont=pozsContWrap.Count; if (numCont!=0) { int[] indsKnotStart=new int[numCont]; for (int iCont=0; iCont<numCont; iCont++) { int pozCont=(int)pozsContWrap[iCont]; indsKnotStart[iCont]=this.Outl.ContourByPoz(pozCont).IndKnotStart; } GErr gerr=new GErrContWrap(this.index, indsKnotStart); gerrlist.Add(gerr); //this.isOrientDefined=false; } /* else { //this.isOrientDefined=true; } */ pozsContWrap.Clear(); return StatusGV.TypeStatusExec.Completed; }
private void CallGV(DefsGV.TypeGV typeGV) { /* * TRY/CATCH function */ /* * MEANING: UNCONDITIONAL call of action */ GErrList gerrlist = null; try { this.statusGV[(int)typeGV].StatusExec = StatusGV.TypeStatusExec.Aborted; this.statusGV[(int)typeGV].StatusRes = StatusGV.TypeStatusRes.Undef; gerrlist = new GErrList(); if (DefsGV.IsModifier(typeGV)) { this.fm.OnGM(this.index, DefsGM.From(typeGV), true); } // check that pre-required tests are performed if (!this.CanBeExec(typeGV)) { this.statusGV[(int)typeGV].StatusExec = StatusGV.TypeStatusExec.UnableToExec; } // call Validate.. function System.Exception excValidation = null; if (this.statusGV[(int)typeGV].StatusExec != StatusGV.TypeStatusExec.UnableToExec) { try { string strTypeCV = Enum.GetName(typeof(DefsGV.TypeGV), typeGV); MethodInfo infoMethod = this.GetType().GetMethod(strTypeCV, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (infoMethod != null) { object[] pars = { gerrlist }; // statusGV can be set to: // Completed || UnableToExec || Aborted try { this.statusGV[(int)typeGV].StatusExec = (StatusGV.TypeStatusExec) infoMethod.Invoke(this, pars); } catch (System.Reflection.TargetInvocationException TIException) { throw TIException.InnerException; } GErrSign.Sign(gerrlist, typeGV, this.index); } if (this.statusGV[(int)typeGV].StatusExec == StatusGV.TypeStatusExec.Completed) { this.statusGV[(int)typeGV].StatusRes = gerrlist.StatusResGV(typeGV); } } catch (System.Exception exc) { excValidation = exc; this.statusGV[(int)typeGV].StatusExec = StatusGV.TypeStatusExec.Aborted; } } if (this.statusGV[(int)typeGV].StatusExec != StatusGV.TypeStatusExec.Completed) { this.CleanUpOnNonCompletedGV(typeGV); GErrValidation gerrVal = new GErrValidation(this.index, this.typeGlyph, typeGV, this.statusGV[(int)typeGV].StatusExec, excValidation); gerrlist.Add(gerrVal); } GErrSign.Sign(gerrlist, typeGV, this.index); this.fm.OnGV(this.index, typeGV, gerrlist); gerrlist.ClearRelease(); } catch (Exception excManagement) // exception thrown by the fm management structures { this.statusGV[(int)typeGV].StatusExec = StatusGV.TypeStatusExec.Aborted; this.CleanUpOnNonCompletedGV(typeGV); // T/C function GErrValidation gerrVal = new GErrValidation(this.index, this.typeGlyph, typeGV, StatusGV.TypeStatusExec.Aborted, excManagement); this.fm.ReportFailure(gerrVal); // T/C function if (gerrlist != null) { try { gerrlist.ClearRelease(); } catch (Exception) {} } } }
internal StatusGV.TypeStatusExec ValidateSimpContDupl(GErrList gerrlist) { if (this.outl==null) { //throw new ExceptionGlyph("Glyph","ValidateSimpContDupl",null); return StatusGV.TypeStatusExec.Aborted; } ListPairInt pairsIndKnotStart=new ListPairInt(); for (int pozContA=0; pozContA<this.outl.NumCont-1; pozContA++) { Contour contA=this.outl.ContourByPoz(pozContA); for (int pozContB=pozContA+1; pozContB<this.outl.NumCont; pozContB++) { Contour contB=this.outl.ContourByPoz(pozContB); bool isDupl; if (!contA.AreDuplicated(contB, out isDupl)) { //throw new ExceptionGlyph("Glyph","ValidateSimpContDupl",null); return StatusGV.TypeStatusExec.Aborted; } if (isDupl) { pairsIndKnotStart.Add(this.outl.ContourByPoz(pozContA).IndKnotStart, this.outl.ContourByPoz(pozContB).IndKnotStart); } } } if (pairsIndKnotStart.Count!=0) { GErr gerr=new GErrContDupl(this.index, pairsIndKnotStart); gerrlist.Add(gerr); //this.isOrientDefined=false; } return StatusGV.TypeStatusExec.Completed; }
internal StatusGV.TypeStatusExec ValidateCompComponentDupl(GErrList gerrlist) { ListPairInt pairsIndComponentDupl=new ListPairInt(); if ((this.comp==null)||(this.outl==null)) { //throw new ExceptionGlyph("Glyph","ValidateCompComponentDupl",null); return StatusGV.TypeStatusExec.Aborted; } int numComponent=this.comp.NumComponent; for (int pozComponentA=0; pozComponentA<numComponent-1; pozComponentA++) { Component componentA=this.comp.ComponentByPoz(pozComponentA); for (int pozComponentB=pozComponentA+1; pozComponentB<numComponent; pozComponentB++) { ListInfoInters linters=new ListInfoInters(); Component componentB=this.comp.ComponentByPoz(pozComponentB); bool areDuplicated; this.outl.AreDuplicatedComponents(componentA,componentB,out areDuplicated); if (areDuplicated) { pairsIndComponentDupl.Add(componentA.IndexGlyphComponent, componentB.IndexGlyphComponent); } } } if (pairsIndComponentDupl.Count!=0) { GErr gerr=new GErrComponentDupl(this.index, pairsIndComponentDupl); gerrlist.Add(gerr); } return StatusGV.TypeStatusExec.Completed; }
internal StatusGV.TypeStatusExec ValidateSimpContInters(GErrList gerrlist) { /* * MEANING: finds ALL intersections: * including D0, D1 and S/I bezier */ ListInfoInters linters = new ListInfoInters(); if (this.outl==null) { //throw new ExceptionGlyph("Glyph","ValidateSimpContInters",null); return StatusGV.TypeStatusExec.Aborted; } if (!this.outl.Intersect(linters)) { //throw new ExceptionGlyph("Glyph","ValidateSimpContInters",null); return StatusGV.TypeStatusExec.Aborted; } if (linters.Count>0) { GErr gerr=new GErrContInters(this.index, linters); gerrlist.Add(gerr); //this.isOrientDefined=false; } return StatusGV.TypeStatusExec.Completed; }
internal StatusGV.TypeStatusExec ValidateCompBind(GErrList gerrlist) { /* * ASSUMPTION: - the glyph is composite and Comp is already * read * - clears outline that is already * built in case of failure to load one * of components */ if (this.outl!=null) { this.outl.ClearDestroy(); this.outl=null; } GErr gerr; bool isCircular=this.fm.PathCompBind.Contains(this.index); if (isCircular) { int numGlyph=this.fm.PathCompBind.Count; int[] pathCompBind=new int[numGlyph+1]; for (int iGlyph=0; iGlyph<numGlyph; iGlyph++) { pathCompBind[iGlyph]=(int)this.fm.PathCompBind[iGlyph]; } pathCompBind[numGlyph]=this.index; gerr=new GErrComponentCircularDependency(this.index, this.index, pathCompBind); gerrlist.Add(gerr); this.fm.PathCompBind.Clear(); return StatusGV.TypeStatusExec.Completed; } if (this.outl!=null) { this.outl.ClearReset(); this.outl=null; } if (this.comp==null) { //throw new ExceptionGlyph("Glyph","ValidateCompBind",null); return StatusGV.TypeStatusExec.Aborted; } this.fm.PathCompBind.Add(this.index); //throw new ArgumentOutOfRangeException(); if (this.comp.NumComponent==0) { this.outl=new Outline(); gerr=new GErrComponentEmpty(this.index,GConsts.IND_UNDEFINED); gerrlist.Add(gerr); return StatusGV.TypeStatusExec.Completed; } foreach (Component component in this.comp) { int indGlyphComponent=component.IndexGlyphComponent; if ((indGlyphComponent<0)||(indGlyphComponent>=this.fm.FNumGlyph)) { gerr=new GErrComponentIndexGlyph(this.index,indGlyphComponent); gerrlist.Add(gerr); this.fm.PathCompBind.Clear(); if (this.outl!=null) { this.outl.ClearDestroy(); this.outl=null; } return StatusGV.TypeStatusExec.Completed; } Glyph glyphComponent=this.fm.GGet(indGlyphComponent); if (glyphComponent==null) { gerr=new GErrComponentLoadFailure(this.index,indGlyphComponent); gerrlist.Add(gerr); this.fm.PathCompBind.Clear(); if (this.outl!=null) { this.outl.ClearDestroy(); this.outl=null; } return StatusGV.TypeStatusExec.Completed; } if (glyphComponent.typeGlyph==GConsts.TypeGlyph.Empty) { gerr=new GErrComponentEmpty(this.index,indGlyphComponent); gerrlist.Add(gerr); continue; } else { if (glyphComponent.Outl==null) { gerr=new GErrComponentLoadFailure(this.index,indGlyphComponent); gerrlist.Add(gerr); this.fm.PathCompBind.Clear(); if (this.outl!=null) { this.outl.ClearDestroy(); this.outl=null; } return StatusGV.TypeStatusExec.Completed; } } if (this.outl==null) { this.outl=new Outline(); } ArrayList errsLoadComponent; if (!this.outl.LoadComponent(component, glyphComponent.outl, out errsLoadComponent)) { this.fm.PathCompBind.Clear(); if (this.outl!=null) { this.outl.ClearDestroy(); this.outl=null; } //throw new ExceptionGlyph("Glyph","ValidateCompBind",null); return StatusGV.TypeStatusExec.Aborted; } if (errsLoadComponent!=null) { foreach (Component.TypeErrLoadComponent errLoadComponent in errsLoadComponent) { gerr=null; switch (errLoadComponent) { case Component.TypeErrLoadComponent.IncorrectShiftSpecification: gerr=new GErrComponentIncorrectShift(this.index, component.IndexGlyphComponent); break; case Component.TypeErrLoadComponent.IncorrectIndexKnotGlyph: gerr=new GErrComponentIndexKnot(this.index, component.IndexGlyphComponent, component.IndexKnotAttGlyph, true); break; case Component.TypeErrLoadComponent.IncorrectIndexKnotComponent: gerr=new GErrComponentIndexKnot(this.index, component.IndexGlyphComponent, component.IndexKnotAttComponent, false); break; case Component.TypeErrLoadComponent.IncorrectTransform: gerr=new GErrComponentIncorrectTransform(this.index, component.IndexGlyphComponent, component.TrOTF2Dot14); break; } gerrlist.Add(gerr); } if (this.outl!=null) { this.outl.ClearDestroy(); this.outl=null; } this.fm.PathCompBind.Clear(); return StatusGV.TypeStatusExec.Completed; } } this.fm.PathCompBind.RemoveAt(this.fm.PathCompBind.Count-1); return StatusGV.TypeStatusExec.Completed; }
internal StatusGV.TypeStatusExec ValidateSimpContMisor(GErrList gerrlist) { if ((this.statusGV[(int)DefsGV.TypeGV.ValidateSimpContDupl].StatusRes!= StatusGV.TypeStatusRes.NoErrors)|| (this.statusGV[(int)DefsGV.TypeGV.ValidateSimpContWrap].StatusRes!= StatusGV.TypeStatusRes.NoErrors)|| (this.statusGV[(int)DefsGV.TypeGV.ValidateSimpContInters].StatusRes!= StatusGV.TypeStatusRes.NoErrors)) { return StatusGV.TypeStatusExec.UnableToExec; } if (this.outl==null) { //throw new ExceptionGlyph("Glyph","ValidateSimpContMisor",null); return StatusGV.TypeStatusExec.Aborted; } ArrayList pozsContMisor=new ArrayList(); for (int pozCont=0; pozCont<this.outl.NumCont; pozCont++) { Contour cont=this.outl.ContourByPoz(pozCont); bool isMisoriented; if (!cont.IsMisoriented(this.outl, out isMisoriented)) { throw new ExceptionGlyph("Glyph","ValidateSimpContMisor",null); //return StatusGV.TypeStatusExec.Aborted; } if (isMisoriented) { pozsContMisor.Add(pozCont); } } int numCont=pozsContMisor.Count; if (numCont!=0) { int[] indsKnotStart=new int[numCont]; for (int iCont=0; iCont<numCont; iCont++) { int pozCont=(int)pozsContMisor[iCont]; indsKnotStart[iCont]=this.Outl.ContourByPoz(pozCont).IndKnotStart; } GErr gerr=new GErrContMisor(this.index, indsKnotStart); gerrlist.Add(gerr); } pozsContMisor.Clear(); return StatusGV.TypeStatusExec.Completed; }