• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ClipperLib.IntPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ClipperLib.IntPoint的典型用法代码示例。如果您正苦于以下问题:C# IntPoint类的具体用法?C# IntPoint怎么用?C# IntPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IntPoint类属于ClipperLib命名空间,在下文中一共展示了IntPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Population

        public Population(int populationSize, Boolean initialise, Paths pgs, IntPoint m_startPoint,Tour greedtour)
        {
            this.oripaths = pgs;   //保存传入的路劲集合,用来计算适应度,及距离
            this.startPoint = m_startPoint;

            tours = new Tour[populationSize];        //种群路劲集合

            int greedseedsize = 15;
            // If we need to initialise a population of tours do so
            if (initialise)
            {
                for (int j = 0; j < greedseedsize; j++)
                {
                    saveTour(j, greedtour);
                }

                // Loop and create individuals
                for (int i = greedseedsize; i < populationSize; i++)
                {
                    Tour newTour = new Tour(pgs.Count);
                    newTour.generateIndividual();
                    saveTour(i, newTour);
                }
            }
        }
开发者ID:Gloriaye,项目名称:laserPathGeneration,代码行数:25,代码来源:Population.cs


示例2: PointMatrix

		public PointMatrix(IntPoint p)
		{
			matrix[0] = p.X;
			matrix[1] = p.Y;
			double f = Sqrt((matrix[0] * matrix[0]) + (matrix[1] * matrix[1]));
			matrix[0] /= f;
			matrix[1] /= f;
			matrix[2] = -matrix[1];
			matrix[3] = matrix[0];
		}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:10,代码来源:IntpointHelper.cs


示例3: ApplyTranslation

		public static void ApplyTranslation(this Polygons polygons, IntPoint translation)
		{
			for (int i = 0; i < polygons.Count; i++)
			{
				for (int j = 0; j < polygons[i].Count; j++)
				{
					polygons[i][j] = polygons[i][j] + translation;
				}
			}
		}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:10,代码来源:PolygonsHelper.cs


示例4: GetPoint

        public static bool GetPoint(Vector2[] quad, bool outter, out List<Vector2> list, bool isClose=true)
        {
            List<IntPoint> quadLines = new List<IntPoint>();
            for(int i=0; i < quad.Length; i++){
                Vector3 from = quad[i];
                IntPoint to = new IntPoint(from.x * DrawHelper.ClipScalling, from.y * DrawHelper.ClipScalling);
                quadLines.Add(to);

                //				IntPoint to = quad[i+1];
                //				to = new IntPoint(to.X * scale.X * scalling, to.Y * scale.Y * scalling);
                //				quadLines.Add(to);
            }

            EndType endType = EndType.etOpenButt;
            if(isClose){
                endType = EndType.etClosedPolygon;
            }

            //Debug.Log("endType: " + endType);

            ClipperOffset co = new ClipperOffset();
            co.AddPath(quadLines, JoinType.jtMiter, endType);
            Paths solution = new Paths();
            double delta = -DrawHelper.WallThick/2 * DrawHelper.ClipScalling;
            if(outter){
                delta = -delta;
            }

            co.MiterLimit = 8;
            co.Execute(ref solution, delta);

            list = new List<Vector2>();

            if(solution.Count > 0){
                foreach(IntPoint p in solution[0]){
                    Vector3 re = new Vector3(p.X * 1.0f/DrawHelper.ClipScalling, p.Y * 1.0f/DrawHelper.ClipScalling, 0f);

                    if(!isClose){
                        //Debug.Log("result: " + re);
                    }

                    list.Add(re);
                }
                list.Add(list[0]);
                return Clipper.Orientation(solution[0]);
            }
            else{
                Debug.LogError("no solution..");
            }

            return true;
        }
开发者ID:zhutaorun,项目名称:unity-drawline,代码行数:52,代码来源:RoomQuad.cs


示例5: IsVertexConcave

        public static bool IsVertexConcave(this Polygon vertices, int vertex)
        {
            IntPoint current = vertices[vertex];
            IntPoint next = vertices[(vertex + 1) % vertices.Count];
            IntPoint previous = vertices[vertex == 0 ? vertices.Count - 1 : vertex - 1];

            IntPoint left = new IntPoint(current.X - previous.X, current.Y - previous.Y);
            IntPoint right = new IntPoint(next.X - current.X, next.Y - current.Y);

            long cross = (left.X * right.Y) - (left.Y * right.X);

            return cross < 0;
        }
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:13,代码来源:PolygonHelper.cs


示例6: InsideOutsidePoints

		public void InsideOutsidePoints()
		{
			{
				// a square with a hole (outside is ccw inside is cw)
				// __________
				// | _____  |
				// | |    | |
				// | |____| |
				// |________|
				string partOutlineString = "x:0, y:0,x:1000, y:0,x:1000, y:1000,x:0, y:1000,|x:100, y:100,x:0, y:900,x:900, y:900,x:900, y:0,|";
				Polygons bounderyPolygons = PolygonsHelper.CreateFromString(partOutlineString);
				AvoidCrossingPerimeters testHarness = new AvoidCrossingPerimeters(bounderyPolygons);
				Assert.IsTrue(testHarness.PointIsInsideBoundary(new IntPoint(1, 1)));
			}

			// Here is a test case that was failing.
			{
				// Looks a little like this
				// _____
				// |   |
				// | O |
				// | O |
				// |___|

				string partOutlineString = "x:90501, y:80501,x:109500, y:80501,x:109500, y:119500,x:90501, y:119500,|x:97387, y:104041,x:95594, y:105213,x:94278, y:106903,x:93583, y:108929,x:93583, y:111071,x:94278, y:113097,x:95594, y:114787,x:97387, y:115959,x:99464, y:116485,x:101598, y:116307,x:103559, y:115447,x:105135, y:113996,x:106154, y:112113,x:106507, y:110000,x:106154, y:107887,x:105135, y:106004,x:103559, y:104553,x:101598, y:103693,x:99464, y:103515,|x:97387, y:84042,x:95594, y:85214,x:94278, y:86904,x:93583, y:88930,x:93583, y:91072,x:94278, y:93098,x:95594, y:94788,x:97387, y:95960,x:99464, y:96486,x:101598, y:96308,x:103559, y:95448,x:105135, y:93997,x:106154, y:92114,x:106507, y:90001,x:106154, y:87888,x:105135, y:86005,x:103559, y:84554,x:101598, y:83694,x:99464, y:83516,|";
				Polygons bounderyPolygons = PolygonsHelper.CreateFromString(partOutlineString);
				IntPoint startPoint = new IntPoint(95765, 114600);
				IntPoint endPoint = new IntPoint(99485, 96234);
				AvoidCrossingPerimeters testHarness = new AvoidCrossingPerimeters(bounderyPolygons);

				{
					IntPoint startPointInside = startPoint;
					testHarness.MovePointInsideBoundary(ref startPointInside);
					IntPoint endPointInside = endPoint;
					testHarness.MovePointInsideBoundary(ref endPointInside);

					Assert.IsTrue(testHarness.PointIsInsideBoundary(startPointInside));
					Assert.IsTrue(testHarness.PointIsInsideBoundary(endPointInside));

					Polygon insidePath = new Polygon();
					testHarness.CreatePathInsideBoundary(startPointInside, endPointInside, insidePath);
					Assert.IsTrue(insidePath.Count > 10); // It needs to go around the cicle so it needs many points (2 is a definate fail).
				}

				{
					Polygon insidePath = new Polygon();
					testHarness.CreatePathInsideBoundary(startPoint, endPoint, insidePath);
					Assert.IsTrue(insidePath.Count > 12); // two more than the last test to get the points in the right place
				}
			}
		}
开发者ID:GearWalker,项目名称:MatterSlice,代码行数:51,代码来源:AvoidCrossingPerimetersTests.cs


示例7: Inside

        public static bool Inside(IList<IntPoint> polygon, IntPoint position, bool toleranceOnOutside = true)
        {
            IntPoint point = position;

            const float epsilon = 0.5f;

            bool inside = false;

            // Must have 3 or more edges
            if (polygon.Count < 3) return false;

            IntPoint oldPoint = polygon[polygon.Count - 1];
            float oldSqDist = (oldPoint - point).LengthSquared();

            for (int i = 0; i < polygon.Count; i++)
            {
                IntPoint newPoint = polygon[i];
                float newSqDist = (newPoint - point).LengthSquared();

                if (oldSqDist + newSqDist + 2.0f * System.Math.Sqrt(oldSqDist * newSqDist) - (newPoint - oldPoint).LengthSquared() < epsilon)
                {
                    return toleranceOnOutside;
                }

                IntPoint left;
                IntPoint right;
                if (newPoint.X > oldPoint.X)
                {
                    left = oldPoint;
                    right = newPoint;
                }
                else
                {
                    left = newPoint;
                    right = oldPoint;
                }

                if (left.X < point.X && point.X <= right.X && (point.Y - left.Y) * (right.X - left.X) < (right.Y - left.Y) * (point.X - left.X))
                {
                    inside = !inside;
                }

                oldPoint = newPoint;
                oldSqDist = newSqDist;
            }

            return inside;
        }
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:48,代码来源:Extra.cs


示例8: Add

        public static List<Vector2> Add(this Shape shape, Shape secondShape, Action<Shape> completed)
        {
            List<Vector2> points = new List<Vector2>();

            Clipper c = new Clipper();

            List<List<IntPoint>> subj = new List<List<IntPoint>>();
            List<List<IntPoint>> clip = new List<List<IntPoint>>();
            List<List<IntPoint>> solution = new List<List<IntPoint>>();
            List<IntPoint> p1 = new List<IntPoint>();
            List<IntPoint> p2 = new List<IntPoint>();
            int i = 0, l = shape.Points.Length;
            Vector2 pos = shape.BuiltGameObject.transform.position;
            for(;i<l;++i)
            {
                IntPoint ip = new IntPoint(shape.Points[i].x + pos.x,shape.Points[i].y + pos.y);
                p1.Add(ip);
            }
            p1.Add(p1[0]);

            pos = secondShape.BuiltGameObject.transform.position;
            i = 0; l = secondShape.Points.Length;
            for(;i<l;++i)
            {
                IntPoint ip = new IntPoint(secondShape.Points[i].x + pos.x,secondShape.Points[i].y + pos.y);
                p2.Add(ip);
            }
            p2.Add(p2[0]);

            subj.Add(p1);
            clip.Add(p2);

            c.AddPaths(subj,PolyType.ptSubject,true);
            c.AddPaths(clip,PolyType.ptClip,true);
            c.Execute(ClipType.ctUnion,solution);

            i = 0; l = solution[0].Count;
            for(;i<l;++i)
            {
                float x = System.Convert.ToSingle(solution[0][i].X);
                float y = System.Convert.ToSingle(solution[0][i].Y);
                points.Add(new Vector2(x,y));
            }

            Mesh2D.Instance.ReBuild(shape.BuiltGameObject,points,completed,shape.Col);
            return points;
        }
开发者ID:DarrenTsung,项目名称:behavior-tree-game,代码行数:47,代码来源:MeshExtensions.cs


示例9: AddPath

        //------------------------------------------------------------------------------
        public void AddPath(List<IntPoint> path, JoinType joinType, EndType endType)
        {
            int highI = path.Count - 1;
            if (highI < 0) return;
            PolyNode newNode = new PolyNode();
            newNode.m_jointype = joinType;
            newNode.m_endtype = endType;

            //strip duplicate points from path and also get index to the lowest point ...
            if (endType == EndType.etClosedLine || endType == EndType.etClosedPolygon)
                while (highI > 0 && path[0] == path[highI]) highI--;
            newNode.m_polygon.Capacity = highI + 1;
            newNode.m_polygon.Add(path[0]);
            int j = 0, k = 0;
            for (int i = 1; i <= highI; i++)
                if (newNode.m_polygon[j] != path[i])
                {
                    j++;
                    newNode.m_polygon.Add(path[i]);
                    if (path[i].Y > newNode.m_polygon[k].Y ||
                      (path[i].Y == newNode.m_polygon[k].Y &&
                      path[i].X < newNode.m_polygon[k].X)) k = j;
                }
            if (endType == EndType.etClosedPolygon && j < 2) return;

            m_polyNodes.AddChild(newNode);

            //if this path's lowest pt is lower than all the others then update m_lowest
            if (endType != EndType.etClosedPolygon) return;
            if (m_lowest.X < 0)
                m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, k);
            else
            {
                IntPoint ip = m_polyNodes.Childs[(int)m_lowest.X].m_polygon[(int)m_lowest.Y];
                if (newNode.m_polygon[k].Y > ip.Y ||
                  (newNode.m_polygon[k].Y == ip.Y &&
                  newNode.m_polygon[k].X < ip.X))
                    m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, k);
            }
        }
开发者ID:JapaMala,项目名称:armok-vision,代码行数:41,代码来源:ClipperOffset.cs


示例10: GetUnitNormal

        //------------------------------------------------------------------------------
        internal static DoublePoint GetUnitNormal(IntPoint pt1, IntPoint pt2)
        {
            double dx = (pt2.X - pt1.X);
            double dy = (pt2.Y - pt1.Y);
            if ((dx == 0) && (dy == 0)) return new DoublePoint();

            double f = 1 * 1.0 / Math.Sqrt(dx * dx + dy * dy);
            dx *= f;
            dy *= f;

            return new DoublePoint(dy, -dx);
        }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:13,代码来源:clipper.cs


示例11: BuildArc

 //------------------------------------------------------------------------------
 // OffsetPolygon functions ...
 //------------------------------------------------------------------------------
 internal static Polygon BuildArc(IntPoint pt, double a1, double a2, double r)
 {
     int steps = Math.Max(6, (int)(Math.Sqrt(Math.Abs(r)) * Math.Abs(a2 - a1)));
     Polygon result = new Polygon(steps);
     int n = steps - 1;
     double da = (a2 - a1) / n;
     double a = a1;
     for (int i = 0; i < steps; ++i)
     {
         result.Add(new IntPoint(pt.X + Round(Math.Cos(a) * r), pt.Y + Round(Math.Sin(a) * r)));
         a += da;
     }
     return result;
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:17,代码来源:clipper.cs


示例12: IsOutside

 public bool IsOutside(Vector2 point)
 {
     var p = new IntPoint(point.X, point.Y);
     return Clipper.PointInPolygon(p, ToClipperPath()) != 1;
 }
开发者ID:Xelamats,项目名称:PortAIO,代码行数:5,代码来源:Geometry.cs


示例13: PointInPolygon

		public static bool PointInPolygon(Polygon polygon, IntPoint testPosition)
		{
			int numPoints = polygon.Count;
			bool result = false;
			for (int i = 0; i < numPoints; i++)
			{
				int prevIndex = i - 1;
				if (prevIndex < 0)
				{
					prevIndex += numPoints;
				}

				if ((((polygon[i].Y <= testPosition.Y) && (testPosition.Y < polygon[prevIndex].Y))
					|| ((polygon[prevIndex].Y <= testPosition.Y) && (testPosition.Y < polygon[i].Y)))
					&& (testPosition.X - polygon[i].X < (polygon[prevIndex].X - polygon[i].X) * (testPosition.Y - polygon[i].Y) / (polygon[prevIndex].Y - polygon[i].Y)))
				{
					result = !result;
				}
			}

			return result;
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:22,代码来源:CreateDiscreteMeshes.cs


示例14: BuildIntersectList

        //------------------------------------------------------------------------------
        private void BuildIntersectList(Int64 botY, Int64 topY)
        {
            if ( m_ActiveEdges == null ) return;

              //prepare for sorting ...
              TEdge e = m_ActiveEdges;
              e.tmpX = TopX( e, topY );
              m_SortedEdges = e;
              m_SortedEdges.prevInSEL = null;
              e = e.nextInAEL;
              while( e != null )
              {
            e.prevInSEL = e.prevInAEL;
            e.prevInSEL.nextInSEL = e;
            e.nextInSEL = null;
            e.tmpX = TopX( e, topY );
            e = e.nextInAEL;
              }

              //bubblesort ...
              bool isModified = true;
              while( isModified && m_SortedEdges != null )
              {
            isModified = false;
            e = m_SortedEdges;
            while( e.nextInSEL != null )
            {
              TEdge eNext = e.nextInSEL;
              IntPoint pt = new IntPoint();
              if(e.tmpX > eNext.tmpX && IntersectPoint(e, eNext, ref pt))
              {
                  if (pt.Y > botY)
                  {
                      pt.Y = botY;
                      pt.X = TopX(e, pt.Y);
                  }
                  AddIntersectNode(e, eNext, pt);
                  SwapPositionsInSEL(e, eNext);
                  isModified = true;
              }
              else
                e = eNext;
            }
            if( e.prevInSEL != null ) e.prevInSEL.nextInSEL = null;
            else break;
              }
              m_SortedEdges = null;
        }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:49,代码来源:clipper.cs


示例15: AddLocalMinPoly

 //------------------------------------------------------------------------------
 private void AddLocalMinPoly(TEdge e1, TEdge e2, IntPoint pt)
 {
     if (e2.dx == horizontal || (e1.dx > e2.dx))
     {
         AddOutPt(e1, e2, pt);
         e2.outIdx = e1.outIdx;
         e1.side = EdgeSide.esLeft;
         e2.side = EdgeSide.esRight;
     }
     else
     {
         AddOutPt(e2, e1, pt);
         e1.outIdx = e2.outIdx;
         e1.side = EdgeSide.esRight;
         e2.side = EdgeSide.esLeft;
     }
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:18,代码来源:clipper.cs


示例16: AddIntersectNode

 //------------------------------------------------------------------------------
 private void AddIntersectNode(TEdge e1, TEdge e2, IntPoint pt)
 {
     IntersectNode newNode = new IntersectNode();
       newNode.edge1 = e1;
       newNode.edge2 = e2;
       newNode.pt = pt;
       newNode.next = null;
       if (m_IntersectNodes == null) m_IntersectNodes = newNode;
       else if( Process1Before2(newNode, m_IntersectNodes) )
       {
     newNode.next = m_IntersectNodes;
     m_IntersectNodes = newNode;
       }
       else
       {
     IntersectNode iNode = m_IntersectNodes;
     while( iNode.next != null  && Process1Before2(iNode.next, newNode) )
         iNode = iNode.next;
     newNode.next = iNode.next;
     iNode.next = newNode;
       }
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:23,代码来源:clipper.cs


示例17: Pt3IsBetweenPt1AndPt2

 //------------------------------------------------------------------------------
 internal bool Pt3IsBetweenPt1AndPt2(IntPoint pt1, IntPoint pt2, IntPoint pt3)
 {
     if (PointsEqual(pt1, pt3) || PointsEqual(pt2, pt3)) return true;
     else if (pt1.X != pt2.X) return (pt1.X < pt3.X) == (pt3.X < pt2.X);
     else return (pt1.Y < pt3.Y) == (pt3.Y < pt2.Y);
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:7,代码来源:clipper.cs


示例18: SwapPoints

 //------------------------------------------------------------------------------
 internal void SwapPoints(ref IntPoint pt1, ref IntPoint pt2)
 {
     IntPoint tmp = pt1;
     pt1 = pt2;
     pt2 = tmp;
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:7,代码来源:clipper.cs


示例19: PointInPolygon

 //------------------------------------------------------------------------------
 internal bool PointInPolygon(IntPoint pt, OutPt pp, bool UseFulllongRange)
 {
     OutPt pp2 = pp;
       bool result = false;
       if (UseFulllongRange)
       {
       do
       {
           if ((((pp2.pt.Y <= pt.Y) && (pt.Y < pp2.prev.pt.Y)) ||
               ((pp2.prev.pt.Y <= pt.Y) && (pt.Y < pp2.pt.Y))) &&
               new Int128(pt.X - pp2.pt.X) <
               Int128.Int128Mul(pp2.prev.pt.X - pp2.pt.X,  pt.Y - pp2.pt.Y) /
               new Int128(pp2.prev.pt.Y - pp2.pt.Y))
                 result = !result;
           pp2 = pp2.next;
       }
       while (pp2 != pp);
       }
       else
       {
       do
       {
           if ((((pp2.pt.Y <= pt.Y) && (pt.Y < pp2.prev.pt.Y)) ||
             ((pp2.prev.pt.Y <= pt.Y) && (pt.Y < pp2.pt.Y))) &&
             (pt.X - pp2.pt.X < (pp2.prev.pt.X - pp2.pt.X) * (pt.Y - pp2.pt.Y) /
             (pp2.prev.pt.Y - pp2.pt.Y))) result = !result;
           pp2 = pp2.next;
       }
       while (pp2 != pp);
       }
       return result;
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:33,代码来源:clipper.cs


示例20: AddLocalMaxPoly

 //------------------------------------------------------------------------------
 private void AddLocalMaxPoly(TEdge e1, TEdge e2, IntPoint pt)
 {
     AddOutPt(e1, null, pt);
     if (e1.outIdx == e2.outIdx)
     {
         e1.outIdx = -1;
         e2.outIdx = -1;
     }
     else AppendPolygon(e1, e2);
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:11,代码来源:clipper.cs



注:本文中的ClipperLib.IntPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ClipperLib.OutPt类代码示例发布时间:2022-05-24
下一篇:
C# ClipperLib.Clipper类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap