public ICylData AsCylData(TolType tolType)
        {
            try
            {
                var pts = new CylData();
                foreach (var v in this)
                {
                    switch (tolType)
                    {
                    case TolType.MAX:
                        pts.Add(new PointCyl(v.RMax, v.ThetaRad, v.Z));
                        break;

                    case TolType.MIN:
                        pts.Add(new PointCyl(v.RMin, v.ThetaRad, v.Z));
                        break;

                    case TolType.NOM:
                        pts.Add(new PointCyl(v.RNom, v.ThetaRad, v.Z));
                        break;
                    }
                }
                return(pts);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        public ICylData CenterToFirstGrooveMidpoint()
        {
            try
            {
                int midCount = (int)Math.Round(data.Count / 2.0);
                var minMax   = GetMinMaxR();

                var rAve   = (minMax.Item1 + minMax.Item2) / 2.0;
                var values = new List <double>();
                for (int i = 0; i < data.Count; i++)
                {
                    values.Add(data[i].R);
                }
                var    interIndex = GetIntersectionIndicesAt(rAve, values);
                int    iMid       = (interIndex[interIndex.Count - 1] + interIndex[0]) / 2;
                double thetaMid   = data[iMid].ThetaRad;

                var transData = new CylData(FileName);
                foreach (var pt in data)
                {
                    transData.Add(new PointCyl(pt.R, pt.ThetaRad - thetaMid, pt.Z));
                }
                return(transData);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        public CylData FitToCircleKnownR(Vector3 pt1, Vector3 pt2, double fitRadius)
        {
            try
            {
                var centers = GeometryLib.GeomUtilities.FindCirclesofKnownR(pt1, pt2, fitRadius);
                var center  = new Vector3();
                if (centers[0].Y > centers[1].Y)
                {
                    center = centers[0];
                }
                else
                {
                    center = centers[1];
                }
                var     translation = new Vector3(-1.0 * center.X, -1.0 * center.Y, 0);
                CylData cylData     = new CylData(this.FileName);
                foreach (var pt  in this)
                {
                    var      pttrans  = pt.Translate(translation);
                    PointCyl pointCyl = new PointCyl(pttrans);

                    cylData.Add(pointCyl);
                }
                return(cylData);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
        public void CalcFitCoeffs(ICylData points)
        {
            try
            {
                if (points.Count <= _polyOrder)
                {
                    _polyOrder = points.Count - 1;
                }

                if (_segmentFit)
                {
                    for (int i = 0; i < points.Count - 1; i++)
                    {
                        var segment = new CylData(points.FileName);
                        var p1      = points[i];
                        var p2      = points[i + 1];
                        segment.Add(p1);
                        segment.Add(p2);
                        var func   = GetFunc(segment);
                        var segFit = new SegmentFitData()
                        {
                            StartPoint  = p1,
                            EndPoint    = p2,
                            FitFunction = func
                        };
                        dataSegments.Add(segFit);
                    }
                }
                else
                {
                    var func   = GetFunc(points);
                    var segFit = new SegmentFitData()
                    {
                        StartPoint  = points[0],
                        EndPoint    = points[points.Count - 1],
                        FitFunction = func
                    };
                    dataSegments.Add(segFit);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #5
0
        public IList <IPointCyl> TrimToWindow(System.Drawing.RectangleF rectangleF, ViewPlane viewPlane)
        {
            try
            {
                var winData = new CylData();
                var dd      = AsDisplayData(viewPlane);
                foreach (var pt in dd)
                {
                    if (rectangleF.Contains(pt))
                    //if (pt.X >= minX && pt.X <= maxX && pt.Y >= minY && pt.Y < maxY)
                    {
                        switch (viewPlane)
                        {
                        case ViewPlane.THETAR:
                            winData.Add(new PointCyl(pt.Y, PointCyl.ToRadians(pt.X), 0));
                            break;

                        case ViewPlane.ZR:
                            winData.Add(new PointCyl(pt.Y, 0, pt.X));
                            break;

                        case ViewPlane.XY:
                            break;

                        case ViewPlane.XZ:
                            break;

                        case ViewPlane.YZ:
                            break;
                        }
                    }
                }
                return(winData);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ICylData AsCylData()
        {
            var stripd = new CylData(this[0].FileName);

            foreach (var strip in this)
            {
                foreach (var pt in strip)
                {
                    var ptnew = new PointCyl(pt.R, pt.ThetaRad, pt.Z, pt.Col, pt.ID);
                    stripd.Add(ptnew);
                }
            }
            return(stripd);
        }
Exemple #7
0
        public ICylData CorrectData(ICylData points)
        {
            try
            {
                var result = new CylData(points.FileName);
                points.SortByTheta();
                for (int i = 0; i < points.Count; i++)
                {
                    var inputPoint = points[i];
                    if (_segmentFit)
                    {
                        foreach (SegmentFitData segment in dataSegments)
                        {
                            if (inputPoint.ThetaRad >= segment.StartPoint.ThetaRad && inputPoint.ThetaRad < segment.EndPoint.ThetaRad)
                            {
                                double r  = inputPoint.R - segment.FitFunction(inputPoint.ThetaRad);
                                var    pt = new PointCyl(r, inputPoint.ThetaRad, inputPoint.Z);
                                result.Add(pt);
                                break;
                            }
                        }
                    }
                    else
                    {
                        double r  = inputPoint.R - dataSegments[0].FitFunction(inputPoint.ThetaRad);
                        var    pt = new PointCyl(r, inputPoint.ThetaRad, inputPoint.Z);
                        result.Add(pt);
                    }
                }

                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public static CylData AsCylData(CartData cartData)
 {
     try
     {
         var strip      = new CylData(cartData.FileName);
         var thetaStart = new PointCyl(cartData[0]).ThetaRad;
         foreach (var pt in cartData)
         {
             var ptCyl = new PointCyl(pt);
             strip.Add(ptCyl);
         }
         return(strip);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #9
0
 public void TrimWidth(double minAngleRads, double maxAngleRads)
 {
     try
     {
         var winData = new CylData();
         foreach (var pt in data)
         {
             if (pt.ThetaRad >= minAngleRads && pt.ThetaRad <= maxAngleRads)
             {
                 winData.Add(pt);
             }
         }
         Clear();
         AddRange(winData);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public CylData CorrectData(CylData points)
        {
            var result = new CylData(points.FileName);

            points.SortByTheta();
            for (int i = 0; i < points.Count; i++)
            {
                foreach (SegmentFitData segmentFit in dataSegments)
                {
                    if (points[i].ThetaRad >= segmentFit.StartPoint.ThetaRad && points[i].ThetaRad < segmentFit.EndPoint.ThetaRad)
                    {
                        double r  = points[i].R - segmentFit.FitFunction(points[i].ThetaRad);
                        var    pt = new PointCyl(r, points[i].ThetaRad, points[i].Z);
                        result.Add(pt);
                        break;
                    }
                }
            }
            return(result);
        }
Exemple #11
0
        private ICylData TranslateToCenter(IVector2 center)
        {
            try
            {
                var     translation = new Vector3(-1.0 * center.X, -1.0 * center.Y, 0);
                CylData cylData     = new CylData(this.FileName);
                foreach (var pt in data)
                {
                    var pttrans = pt.Translate(translation);

                    PointCyl pointCyl = new PointCyl(pttrans);

                    cylData.Add(pointCyl);
                }
                return(cylData);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// get single groove from ring data set
        /// </summary>
        /// <param name="grooveNumber"></param>
        /// <param name="ring"></param>
        /// <returns></returns>
        //static public CylData GetGrooveFromRing(Barrel barrel, int grooveNumber, CylData ring)
        //{
        //    try
        //    {
        //        double z = (ring[0].Z + ring[ring.Count - 1].Z) / 2.0;


        //        var groove = new CylData();
        //        foreach (PointCyl bp in ring)
        //        {
        //            int gn = barrel.GetGrooveNumber(bp.Z, bp.ThetaRad);
        //            if (gn == grooveNumber)
        //            {
        //                groove.Add(bp);
        //            }

        //        }
        //        return groove;
        //    }
        //    catch (Exception)
        //    {

        //        throw;
        //    }

        //}
        /// <summary>
        /// get section from ring data set
        /// </summary>
        /// <param name="startIndex"></param>
        /// <param name="endIndex"></param>
        /// <param name="ring"></param>
        /// <returns></returns>
        static public CylData GetSectionFromRing(int startIndex, int endIndex, CylData ring)
        {
            try
            {
                double z = (ring[0].Z + ring[ring.Count - 1].Z) / 2.0;


                var groove = new CylData(ring.FileName);
                foreach (PointCyl bp in ring)
                {
                    if (bp.ID >= startIndex && bp.ID < endIndex)
                    {
                        groove.Add(bp);
                    }
                }
                return(groove);
            }
            catch (Exception)
            {
                throw;
            }
        }
 /// <summary>
 /// get first full ring from multi ring data set
 /// </summary>
 /// <param name="passIndex"></param>
 /// <param name="ring"></param>
 /// <returns></returns>
 static public CylData GetFirstRingFromMultiPassRing(int passIndex, CylData ring)
 {
     try
     {
         double startTh = ring[0].ThetaRad;
         double endTh   = startTh + (Math.PI * 2.0);
         var    result  = new CylData(ring.FileName);
         foreach (PointCyl bp in ring)
         {
             if (bp.ThetaRad >= startTh && bp.ThetaRad <= endTh)
             {
                 result.Add(bp);
             }
         }
         result.MinRadius = ring.MinRadius;
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public static CylData CenterToThetaRadMidpoint(CylData data)
        {
            int    midCount = (int)Math.Round(data.Count / 2.0);
            var    minMax   = data.GetMinMaxR();
            var    midRData = (minMax.Item1 + minMax.Item2) / 2.0;
            double x1       = 0;

            for (int i = 1; i < midCount; i++)
            {
                if ((data[i - 1].R <midRData && data[i].R> midRData) ||
                    (data[i - 1].R > midRData && data[i].R < midRData))
                {
                    x1 = (data[i - 1].ThetaRad + data[i].ThetaRad) / 2.0;
                    break;
                }
            }
            double x2 = 0;

            for (int i = midCount; i < data.Count; i++)
            {
                if ((data[i - 1].R <midRData && data[i].R> midRData) ||
                    (data[i - 1].R > midRData && data[i].R < midRData))
                {
                    x2 = (data[i - 1].ThetaRad + data[i].ThetaRad) / 2.0;
                    break;
                }
            }
            double midThetaRad = (x1 + x2) / 2.0;
            var    transData   = new CylData(data.FileName);

            foreach (var pt in data)
            {
                transData.Add(new PointCyl(pt.R, pt.ThetaRad - midThetaRad, pt.Z));
            }
            return(transData);
        }