Ejemplo n.º 1
0
 public static TempContext <PolygonSimplifier> BorrowPolygonSimplifier(out PolygonSimplifier flattener)
 {
     if (!Temp <PolygonSimplifier> .IsInit())
     {
         Temp <PolygonSimplifier> .SetNewHandler(
             () => new PolygonSimplifier(),
             f => f.Reset());
     }
     return(Temp <PolygonSimplifier> .Borrow(out flattener));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Transform accumulated pointer input to ink geometry
        /// </summary>
        /// <param name="defaultSize">Default size for SplineInterpolator and BrushApplier</param>
        /// <param name="defaultScale">Default Scale for BrushApplier</param>
        /// <param name="defaultOffset">Default Offset for BrushApplier</param>
        /// <param name="defaultRotation">Default Rotation for BrushApplier</param>
        /// <returns>Tuple containing added data (Item1) and predicted or preliminary data (Item2)</returns>
        /// <remarks>Passes accumulated path segment (from PathProducer) through remaining stages of
        /// the vector ink pipeline - Smoother, SplineProducer, SplineInterpolator, BrushApplier, ConvexHullChainProducer,
        /// PolygonMerger and PolygonSimplifier</remarks>
        public ProcessorResult <List <PolygonVertices> > GetPolygons()
        {
            var smoothPath = mSmoothingFilter.Add(mPathSegment.IsFirst, mPathSegment.IsLast, mPathSegment.AccumulatedAddition, mPathSegment.LastPrediction);

            var spline = SplineProducer.Add(mPathSegment.IsFirst, mPathSegment.IsLast, smoothPath.Addition, smoothPath.Prediction);

            var points = SplineInterpolator.Add(mPathSegment.IsFirst, mPathSegment.IsLast, spline.Addition, spline.Prediction);

            var polys = BrushApplier.Add(mPathSegment.IsFirst, mPathSegment.IsLast, points.Addition, points.Prediction);

            var hulls = ConvexHullChainProducer.Add(mPathSegment.IsFirst, mPathSegment.IsLast, polys.Addition, polys.Prediction);

            var merged = mPolygonMerger.Add(mPathSegment.IsFirst, mPathSegment.IsLast, hulls.Addition, hulls.Prediction);

            var simplified = PolygonSimplifier.Add(mPathSegment.IsFirst, mPathSegment.IsLast, merged.Addition, merged.Prediction);

            mPathSegment.Reset();

            return(simplified);
        }
        private static List <List <DataPoint> > SimplifyBoundary(PolygonBoundary boundary)
        {
            var points = boundary.Points;

            List <DataPoint> xyPoints = new List <DataPoint>();

            foreach (var point in points)
            {
                double ptX = 0;
                double ptY = 0;
                point.GetCoordinates(out ptX, out ptY);
                DataPoint dataPoint = new DataPoint(ptX, ptY);
                xyPoints.Add(dataPoint);
            }

            // need to turn these into a set of triangles
            List <List <DataPoint> > simpleAreaSet =
                PolygonSimplifier.TriangulatePolygon(xyPoints);

            return(simpleAreaSet);
        }
        public static List <List <Point3D> > SimplifyBoundary(PolygonBoundary boundary)
        {
            List <PolygonPoint> points = boundary.Points;

            List <Point3D> xyPoints = new List <Point3D>();

            foreach (PolygonPoint point in points)
            {
                double ptX;
                double ptY;
                point.GetCoordinates(out ptX, out ptY);
                Point3D dataPoint = new Point3D(ptX, ptY, 0);
                xyPoints.Add(dataPoint);
            }

            // need to turn these into a set of triangles
            List <List <Point3D> > simpleAreaSet =
                PolygonSimplifier.TriangulatePolygon(xyPoints);

            return(simpleAreaSet);
        }
Ejemplo n.º 5
0
        public void UpdatePipeline(PathPointLayout layout, Calculator calculator, VectorBrush brush)
        {
            bool layoutChanged = false;

            if ((Layout == null) || (layout.ChannelMask != Layout.ChannelMask))
            {
                Layout        = layout;
                layoutChanged = true;
            }

            if (mPathProducer == null || calculator != mPathProducer.PathPointCalculator || layoutChanged)
            {
                mPathProducer = new PathProducer(Layout, calculator)
                {
                    KeepAllData = true
                };
            }

            if (mSmoothingFilter == null || layoutChanged)
            {
                mSmoothingFilter = new SmoothingFilter(Layout.Count)
                {
                    KeepAllData = true
                };
            }

            if (SplineProducer == null || layoutChanged)
            {
                SplineProducer = new SplineProducer(Layout)
                {
                    KeepAllData = true
                };
            }

            if (SplineInterpolator == null || layoutChanged)
            {
                SplineInterpolator = new CurvatureBasedInterpolator(Layout)
                {
                    KeepAllData = true
                };
            }

            if (BrushApplier == null || (brush != BrushApplier.Prototype) || layoutChanged)
            {
                BrushApplier = new BrushApplier(Layout, brush)
                {
                    KeepAllData = true
                };
            }

            if (ConvexHullChainProducer == null)
            {
                ConvexHullChainProducer = new ConvexHullChainProducer()
                {
                    KeepAllData = true
                };
            }

            if (mPolygonMerger == null)
            {
                mPolygonMerger = new PolygonMerger()
                {
                    KeepAllData = true
                };
            }

            if (PolygonSimplifier == null)
            {
                PolygonSimplifier = new PolygonSimplifier(0.1f)
                {
                    KeepAllData = true
                };
            }
        }