예제 #1
0
 public void Unite(BoxD box)
 {
     this.vecMin.From(Math.Min(this.vecMin.X, box.VecMin.X),
                      Math.Min(this.vecMin.Y, box.VecMin.Y));
     this.vecMax.From(Math.Max(this.vecMax.X, box.VecMax.X),
                      Math.Max(this.vecMax.Y, box.VecMax.Y));
 }
예제 #2
0
        /*
         *        METHODS
         */
        override public bool Equals(object obj)
        {
            BoxD box = obj as BoxD;

            if ((object)box == null)
            {
                return(false);
            }
            return((this.VecMax == box.VecMax) && (this.VecMin == box.VecMin));
        }
예제 #3
0
        public bool HasInters(BoxD box)
        {
            if (box == null)
            {
                return(false);
            }
            if ((this.IsEmpty) || (box.IsEmpty))
            {
                return(false);
            }
            bool notInters = (box.VecMin.X > this.vecMax.X) ||
                             (box.VecMax.X < this.vecMin.X) ||
                             (box.VecMin.Y > this.vecMax.Y) ||
                             (box.VecMax.Y < this.vecMin.Y);

            return(!notInters);
        }
예제 #4
0
        public bool Intersect(Contour cont, ListInfoInters linters)
        {
            Contour contA = this;
            Contour contB = cont;

            if (contA == contB)
            {
                return(this.Intersect(linters));
            }
            BoxD bboxContA = contA.BBox;
            BoxD bboxContB = contB.BBox;

            if (!bboxContA.HasInters(bboxContB))
            {
                return(true);
            }

            for (int pozA = 0; pozA < contA.NumKnot; pozA++)
            {
                Knot   knA    = contA.KnotByPoz(pozA);
                BCurve curveA = contA.CurveByPoz(pozA);
                if (curveA != null)
                {
                    BoxD bboxCurveA = curveA.BBox;
                    if (bboxCurveA.HasInters(bboxContB))
                    {
                        for (int pozB = 0; pozB < contB.NumKnot; pozB++)
                        {
                            BCurve curveB = contB.CurveByPoz(pozB);
                            if (curveB != null)
                            {
                                int numIntersBefore = linters.Count;
                                Inters.IntersectBB(curveA, curveB, null, null, linters);
                                Knot knB = contB.KnotByPoz(pozB);
                                linters.ParamToCParam(knA, knB, numIntersBefore);
                            }
                        }
                    }
                }
            }

            contA = null;
            contB = null;
            return(true);
        }
예제 #5
0
 public double DeviationMax(BoxD box)
 {
     if ((this.IsEmpty)||(box.IsEmpty))
         return -MConsts.Infinity;
     double[] devs=new double[4];
     devs[0]=this.vecMin.X-box.VecMin.X;
     devs[1]=this.vecMin.Y-box.VecMin.Y;
     devs[2]=this.vecMax.X-box.VecMax.X;
     devs[3]=this.vecMax.Y-box.VecMax.Y;
     double devMax=0.0;
     for (int iDev=0; iDev<4; iDev++)
     {
         double devCur=Math.Abs(devs[iDev]);
         if (devCur>devMax)
         {
             devMax=devCur;
         }
     }
     return devMax;
 }
예제 #6
0
        public double DeviationMax(BoxD box)
        {
            if ((this.IsEmpty) || (box.IsEmpty))
            {
                return(-MConsts.Infinity);
            }
            double[] devs = new double[4];
            devs[0] = this.vecMin.X - box.VecMin.X;
            devs[1] = this.vecMin.Y - box.VecMin.Y;
            devs[2] = this.vecMax.X - box.VecMax.X;
            devs[3] = this.vecMax.Y - box.VecMax.Y;
            double devMax = 0.0;

            for (int iDev = 0; iDev < 4; iDev++)
            {
                double devCur = Math.Abs(devs[iDev]);
                if (devCur > devMax)
                {
                    devMax = devCur;
                }
            }
            return(devMax);
        }
예제 #7
0
 public BoxD(BoxD box) : this(box.VecMin, box.VecMax)
 {
 }
예제 #8
0
 public BoxD(BoxD box): this(box.VecMin, box.VecMax)
 {    
 }
예제 #9
0
 public bool HasInters(BoxD box)
 {
     if (box==null)
         return false;
     if ((this.IsEmpty)||(box.IsEmpty))
         return false;
     bool notInters=(box.VecMin.X>this.vecMax.X)||
         (box.VecMax.X<this.vecMin.X)||
         (box.VecMin.Y>this.vecMax.Y)||
         (box.VecMax.Y<this.vecMin.Y);
     return (!notInters);
 }
예제 #10
0
 public void Unite(BoxD box)
 {
     this.vecMin.From(Math.Min(this.vecMin.X,box.VecMin.X),
         Math.Min(this.vecMin.Y,box.VecMin.Y));
     this.vecMax.From(Math.Max(this.vecMax.X,box.VecMax.X),
         Math.Max(this.vecMax.Y,box.VecMax.Y));
 }
예제 #11
0
 protected override void ClearFunc()
 {
     this.bboxCP=null;
     this.bboxOutl=null;
 }
예제 #12
0
        public GErrExtremeNotOnCurve(int indGlyph, 
            GConsts.TypeGlyph typeGlyph,
            BoxD bboxCP, BoxD bboxOutl) 
        {
            // ValInfoBasic
            base.TypeBasic = ValInfoType.Warning;
            base.Name = "GERR_EXTEREME_NOT_ON_CURVE";
            base.ValueUser = null;
            base.NameFileErrs = GErrConsts.FILE_RES_GERR_STRINGS;
            base.NameAsmFileErrs = GErrConsts.ASM_RES_GERR_STRINGS;
            base.TagPrincipal = "glyf";

            // GErr
            base.indexGlyphOwner =indGlyph;
            base.severity = GErr.TypeGErrSeverity.Middle;
            base.SetScope(GScope.TypeGScope._GGB_,GScope.TypeGScope._GGO_);
            base.typeGlyph=typeGlyph;
            
            // this
            this.bboxCP=new BoxD(bboxCP);
            this.bboxOutl=new BoxD(bboxOutl);
        }
예제 #13
0
        public GErrBBox(int indGlyph, GConsts.TypeGlyph typeGlyph,
            BoxD bboxInit, BoxD bboxCP) 
        {
            // ValInfoBasic
            base.TypeBasic = ValInfoType.Error;
            base.Name = "GERR_BBOX";
            base.ValueUser = null;
            base.NameFileErrs = GErrConsts.FILE_RES_GERR_STRINGS;
            base.NameAsmFileErrs = GErrConsts.ASM_RES_GERR_STRINGS;
            base.TagPrincipal = "glyf";

            // GErr
            base.indexGlyphOwner =indGlyph;
            base.severity = GErr.TypeGErrSeverity.Middle;
            base.SetScope(GScope.TypeGScope._GGB_,GScope.TypeGScope._GGO_);
            base.typeGlyph=typeGlyph;
            
            // this
            this.bboxInit=new BoxD(bboxInit);
            this.bboxCP=new BoxD(bboxCP);
        }
예제 #14
0
        public static bool IntersectBB(BCurve curveA, BCurve curveB,
                                       InfoConnect icAB, InfoConnect icBA, ListInfoInters linters)
        {
            BoxD bboxA = curveA.BBox;
            BoxD bboxB = curveB.BBox;

            if (!bboxA.HasInters(bboxB))
            {
                return(true);
            }

            int numIntersBefore = linters.Count;

            bool connectAB             = (icAB != null) && (icAB.IsConnect);
            bool connectBA             = (icBA != null) && (icBA.IsConnect);
            bool toReverseByConnection = (connectBA) && (!connectAB);

            if (toReverseByConnection)
            {
                if (!Inters.IntersectBB(curveB, curveA, icBA, icAB, linters))
                {
                    return(false);
                }
                linters.ParamSwap(numIntersBefore);
                return(false);
            }

            BCurve redA = curveA.Reduced;
            BCurve redB = curveB.Reduced;
            bool   toReverseByComplexity = (redA.BComplexity > redB.BComplexity);

            object[] pars = { redA, redB, icAB, icBA, linters };
            if (toReverseByComplexity)
            {
                // TODO: check !!!
                // TODO: what happens with connection info ???
                pars[0] = redB.Reversed;
                pars[1] = redA.Reversed;
            }

            Type[]     types = { pars[0].GetType(), pars[1].GetType(),
                                 typeof(InfoConnect),   typeof(InfoConnect), typeof(ListInfoInters) };
            MethodInfo infoMethod = typeof(Inters).GetMethod("AuxIntersectBB", types);
            bool       res;

            try
            {
                res = (bool)infoMethod.Invoke(null, pars);
            }
            catch (System.Reflection.TargetInvocationException TIException)
            {
                throw TIException.InnerException;
            }

            if (toReverseByComplexity)
            {
                linters.ParamReverse(1, 0, numIntersBefore);
                linters.ParamReverse(1, 1, numIntersBefore);
                linters.ParamSwap(numIntersBefore);
            }
            if ((object)redA != (object)curveA)
            {
                linters.ParamFromReduced(curveA, 0, numIntersBefore);
            }
            if ((object)redB != (object)curveB)
            {
                linters.ParamFromReduced(curveB, 1, numIntersBefore);
            }

            // clean-up end-point intersections
            linters.CleanEndPointInters(connectAB, connectBA, numIntersBefore);
            return(res);
        }
예제 #15
0
        public Glyph(int indexGlyph, FManager fm)
        {
            this.fm=fm;

            this.index=indexGlyph;
            this.typeGlyph=GConsts.TypeGlyph.Uninitialized;
            this.bbox=null;
            this.outl=null;
            this.comp=null;

            this.statusGV=new StatusGV[DefsGV.NumTest];
            for (int iTest=0; iTest<DefsGV.NumTest; iTest++)
            {
                this.statusGV[iTest]=new StatusGV();
            }
        }
예제 #16
0
        private void CleanUpOnNonCompletedGV(DefsGV.TypeGV typeGV)
        {
            /*
             *        TRY/CATCH function
             */
            switch (typeGV)
            {
                case DefsGV.TypeGV.ValidateTypeGlyphSource:
                    this.typeGlyph=GConsts.TypeGlyph.Undef;
                    break;
                case DefsGV.TypeGV.ValidateSimpSource:
                    if (this.bbox!=null)
                        this.bbox=null;
                    if (this.outl!=null)
                    {
                        try 
                        {
                            this.outl.ClearDestroy();
                        }
                        catch(System.Exception)
                        {
                        }
                        this.outl=null;
                    }
                    break;
                case DefsGV.TypeGV.ValidateCompSource:
                    if (this.bbox!=null)
                        this.bbox=null;
                    if (this.comp!=null)
                    {
                        try 
                        {
                            this.comp.ClearDestroy();
                        }
                        catch(System.Exception)
                        {
                        }
                        this.comp=null;
                    }
                    break;
                case DefsGV.TypeGV.ValidateCompBind:
                    if (this.outl!=null)
                    {
                        try 
                        {
                            this.outl.ClearDestroy();
                        }
                        catch(System.Exception)
                        {
                        }
                        this.outl=null;
                    }
                    break;
            }
            
            /*
            private int index;
            private GConsts.TypeGlyph typeGlyph;
            BoxD        bbox;
            Outline        outl;
            Composite    comp;
            private FManager        fm;        
            private StatusGV[]        statusGV;
            */



        }
예제 #17
0
        public void ClearDestroy()
        {
            if (this.bbox!=null)
            {
                this.bbox.Clear();
                this.bbox=null;
            }
            if (this.comp!=null)
            {
                this.comp.ClearDestroy();
                this.comp=null;
            }
            if (this.outl!=null)
            {
                this.outl.ClearDestroy();
                this.outl=null;
            }
            if (this.statusGV!=null)
            {
                this.statusGV=null;
            }
            this.index=GConsts.IND_UNINITIALIZED;
            this.fm=null;

        }
예제 #18
0
 public void ClearRelease()
 {
     if (this.bbox!=null)
     {
         this.bbox.Clear();
         this.bbox=null;
     }
     if (this.comp!=null)
     {
         this.comp.ClearRelease();
         this.comp=null;
     }
     if (this.outl!=null)
     {
         this.outl.ClearRelease();
         this.outl=null;
     }
     this.index=GConsts.IND_UNINITIALIZED;
     this.fm=null;
 }
예제 #19
0
        // TODO: rewrite
        public void ReadFontMetrics(out int descendMin, 
            out int ascendMax,    
            out int lsbMin, 
            out int rsbMax, 
            DIAction dia)
        {
            descendMin=-700;
            ascendMax=2100;
            lsbMin=-1000;
            rsbMax=3500;

            try
            {
                BoxD bboxRes=new BoxD();

                Table_cmap tableCmap = (Table_cmap)this.m_font.GetTable("cmap");
                if (tableCmap==null)
                    return;
                Table_cmap.EncodingTableEntry eteUni = 
                    tableCmap.GetEncodingTableEntry(3,1);
                if (eteUni==null)
                    return;
                Table_cmap.Subtable subtableCmap = tableCmap.GetSubtable(eteUni);
                char[] samples={'A','W','p'};
                for (int iSample=0; iSample<samples.Length; iSample++)
                {                
                    byte[] charbuf = new byte[2];
                    charbuf[0] = (byte)'A';
                    charbuf[1] = 0; 
                    int indGlyph = (int)subtableCmap.MapCharToGlyph(charbuf, 0);
                    Table_glyf.header header=this.m_tableGlyf.GetGlyphHeader((uint)indGlyph,this.m_font);
                    if (header==null)
                        return;
                    BoxD bboxCur=new BoxD(header.xMin, header.yMin,
                        header.xMax, header.yMax);
                    bboxRes.Unite(bboxCur);
                }
                descendMin=(int)bboxRes.VecMin.Y;
                ascendMax=(int)bboxRes.VecMax.Y;
                lsbMin=(int)bboxRes.VecMin.X;
                rsbMax=(int)bboxRes.VecMax.X;
            }
            catch
            {
            }
        }
예제 #20
0
        public void ReadGGB(int indexGlyph, 
            out BoxD bbox, 
            DIAction dia)
        {
            this.m_validator.DIA=dia;

            bbox=null;
            
            int offsStart, length;
            if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph, 
                out offsStart, out length, this.m_validator, this.m_font))
                return;
            if (length==0)
                return;
            short xMin, yMin, xMax, yMax;
            if ((int)Table_glyf.FieldOffsets.nextAfterHeader>=length)
            {
                this.m_validator.Error(
                    E._GEN_E_OffsetExceedsTableLength, 
                    (OTTag)"glyf");
                return;
            }
            
            MBOBuffer buffer=this.m_tableGlyf.Buffer;
            xMin=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.xMin));
            yMin=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.yMin));
            xMax=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.xMax));
            yMax=buffer.GetShort((uint)(offsStart+(int)Table_glyf.FieldOffsets.yMax));
            bbox=new BoxD(xMin,yMin,xMax,yMax);
        }
예제 #21
0
        internal StatusGV.TypeStatusExec ValidateCompSource(GErrList gerrlist)
        {
            if (this.bbox!=null)
            {
                this.bbox.Clear();
                this.bbox=null;
            }
            if (this.comp!=null)
            {
                this.comp.ClearDestroy();
                this.comp=null;
            }
            if (this.outl!=null)
            {
                this.outl.ClearDestroy();
                this.outl=null;
            }    
            
            if (this.typeGlyph==GConsts.TypeGlyph.Empty)
            {
                return StatusGV.TypeStatusExec.Completed;
            }
            if (this.typeGlyph!=GConsts.TypeGlyph.Composite)            
            {
                //throw new ExceptionGlyph("Glyph","ValidateCompSource",null);
                return StatusGV.TypeStatusExec.Aborted;
            }
            DIAction dia=DIActionBuilder.DIA(gerrlist,"DIAFunc_AddToListUnique");
            gerrlist.DIW=new DIWrapperSource(this.index,this.typeGlyph,GScope.TypeGScope._GGB_);

            I_IOGlyphs i_IOGlyphs=this.fm.IIOGlyphs;
            if (i_IOGlyphs==null)
            {
                //throw new ExceptionGlyph("Glyph","ValidateCompSource",null);
                return StatusGV.TypeStatusExec.Aborted;
            }
            i_IOGlyphs.ReadGGB(this.index, out this.bbox, dia);
            i_IOGlyphs.ReadGGC(this.index, out this.comp, dia);
            if (this.comp!=null)
            {
                this.fm.OnGComposite(this.index);
            }


            gerrlist.DIW=null;
            return StatusGV.TypeStatusExec.Completed;        
        }