当前位置: 首页>>代码示例>>C#>>正文


C# ClipperLib.OutPt类代码示例

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


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

示例1: Poly2ContainsPoly1

 //------------------------------------------------------------------------------
 private static bool Poly2ContainsPoly1(OutPt outPt1, OutPt outPt2)
 {
     OutPt op = outPt1;
     do
     {
         //nb: PointInPolygon returns 0 if false, +1 if true, -1 if pt on polygon
         int res = PointInPolygon(op.Pt, outPt2);
         if (res >= 0) return res > 0;
         op = op.Next;
     }
     while (op != outPt1);
     return true;
 }
开发者ID:JapaMala,项目名称:armok-vision,代码行数:14,代码来源:Clipper.cs

示例2: 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

示例3: AddOutPt

 //------------------------------------------------------------------------------
 private void AddOutPt(TEdge e, TEdge altE, IntPoint pt)
 {
     bool ToFront = (e.side == EdgeSide.esLeft);
       if(  e.outIdx < 0 )
       {
       OutRec outRec = CreateOutRec();
       m_PolyOuts.Add(outRec);
       outRec.idx = m_PolyOuts.Count -1;
       e.outIdx = outRec.idx;
       OutPt op = new OutPt();
       outRec.pts = op;
       outRec.bottomPt = op;
       outRec.bottomE1 = e;
       outRec.bottomE2 = altE;
       op.pt = pt;
       op.idx = outRec.idx;
       op.next = op;
       op.prev = op;
       SetHoleState(e, outRec);
       } else
       {
       OutRec outRec = m_PolyOuts[e.outIdx];
       OutPt op = outRec.pts;
       if (ToFront && PointsEqual(pt, op.pt) ||
           (!ToFront && PointsEqual(pt, op.prev.pt))) return;
       OutPt op2 = new OutPt();
       op2.pt = pt;
       op2.idx = outRec.idx;
       if (op2.pt.Y == outRec.bottomPt.pt.Y &&
         op2.pt.X < outRec.bottomPt.pt.X)
       {
           outRec.bottomPt = op2;
           outRec.bottomE1 = e;
           outRec.bottomE2 = altE;
       }
       op2.next = op;
       op2.prev = op.prev;
       op2.prev.next = op2;
       op.prev = op2;
       if (ToFront) outRec.pts = op2;
       }
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:43,代码来源:clipper.cs

示例4: InsertPolyPtBetween

 //------------------------------------------------------------------------------
 private OutPt InsertPolyPtBetween(OutPt p1, OutPt p2, IntPoint pt)
 {
     OutPt result = new OutPt();
     result.pt = pt;
     if (p2 == p1.next)
     {
         p1.next = result;
         p2.prev = result;
         result.next = p2;
         result.prev = p1;
     } else
     {
         p2.next = result;
         p1.prev = result;
         result.next = p1;
         result.prev = p2;
     }
     return result;
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:20,代码来源:clipper.cs

示例5: PolygonBottom

 //------------------------------------------------------------------------------
 private OutPt PolygonBottom(OutPt pp)
 {
     OutPt p = pp.next;
     OutPt result = pp;
     while (p != pp)
     {
     if (p.pt.Y > result.pt.Y) result = p;
     else if (p.pt.Y == result.pt.Y && p.pt.X < result.pt.X) result = p;
     p = p.next;
     }
     return result;
 }
开发者ID:colin-dumitru,项目名称:Collaborative-Whiteboard,代码行数:13,代码来源:clipper.cs

示例6: JoinPoints

        //------------------------------------------------------------------------------

        private bool JoinPoints(JoinRec j, out OutPt p1, out OutPt p2)
        {
            p1 = null; p2 = null;
            OutRec outRec1 = m_PolyOuts[j.poly1Idx];
            OutRec outRec2 = m_PolyOuts[j.poly2Idx];
            if (outRec1  == null || outRec2 == null)  return false;  
            OutPt pp1a = outRec1.pts;
            OutPt pp2a = outRec2.pts;
            IntPoint pt1 = j.pt2a, pt2 = j.pt2b;
            IntPoint pt3 = j.pt1a, pt4 = j.pt1b;
            if (!FindSegment(ref pp1a, ref pt1, ref pt2)) return false;
            if (outRec1 == outRec2)
            {
              //we're searching the same polygon for overlapping segments so
              //segment 2 mustn't be the same as segment 1 ...
              pp2a = pp1a.next;
              if (!FindSegment(ref pp2a, ref pt3, ref pt4) || (pp2a == pp1a)) return false;
            }
            else if (!FindSegment(ref pp2a, ref pt3, ref pt4)) return false;

            if (!GetOverlapSegment(pt1, pt2, pt3, pt4, ref pt1, ref pt2)) return false;

            OutPt p3, p4, prev = pp1a.prev;
            //get p1 & p2 polypts - the overlap start & endpoints on poly1
            if (PointsEqual(pp1a.pt, pt1)) p1 = pp1a;
            else if (PointsEqual(prev.pt, pt1)) p1 = prev;
            else p1 = InsertPolyPtBetween(pp1a, prev, pt1);

            if (PointsEqual(pp1a.pt, pt2)) p2 = pp1a;
            else if (PointsEqual(prev.pt, pt2)) p2 = prev;
            else if ((p1 == pp1a) || (p1 == prev))
              p2 = InsertPolyPtBetween(pp1a, prev, pt2);
            else if (Pt3IsBetweenPt1AndPt2(pp1a.pt, p1.pt, pt2))
              p2 = InsertPolyPtBetween(pp1a, p1, pt2); else
              p2 = InsertPolyPtBetween(p1, prev, pt2);

            //get p3 & p4 polypts - the overlap start & endpoints on poly2
            prev = pp2a.prev;
            if (PointsEqual(pp2a.pt, pt1)) p3 = pp2a;
            else if (PointsEqual(prev.pt, pt1)) p3 = prev;
            else p3 = InsertPolyPtBetween(pp2a, prev, pt1);

            if (PointsEqual(pp2a.pt, pt2)) p4 = pp2a;
            else if (PointsEqual(prev.pt, pt2)) p4 = prev;
            else if ((p3 == pp2a) || (p3 == prev))
              p4 = InsertPolyPtBetween(pp2a, prev, pt2);
            else if (Pt3IsBetweenPt1AndPt2(pp2a.pt, p3.pt, pt2))
              p4 = InsertPolyPtBetween(pp2a, p3, pt2); else
              p4 = InsertPolyPtBetween(p3, prev, pt2);

            //p1.pt == p3.pt and p2.pt == p4.pt so join p1 to p3 and p2 to p4 ...
            if (p1.next == p2 && p3.prev == p4)
            {
              p1.next = p3;
              p3.prev = p1;
              p2.prev = p4;
              p4.next = p2;
              return true;
            }
            else if (p1.prev == p2 && p3.next == p4)
            {
              p1.prev = p3;
              p3.next = p1;
              p2.next = p4;
              p4.prev = p2;
              return true;
            }
            else
              return false; //an orientation is probably wrong
        }
开发者ID:caomw,项目名称:elementdiscovery,代码行数:72,代码来源:clipper.cs

示例7: Poly2ContainsPoly1

        //----------------------------------------------------------------------

        private bool Poly2ContainsPoly1(OutPt outPt1, OutPt outPt2, bool UseFullInt64Range)
        {
            //find the first pt in outPt1 that isn't also a vertex of outPt2 ...
            OutPt outPt = outPt1;
            do
            {
                if (!PointIsVertex(outPt.pt, outPt2)) break;
                outPt = outPt.next;
            }
            while (outPt != outPt1);
            bool result;
            //sometimes a point on one polygon can be touching the other polygon 
            //so to be totally confident outPt1 is inside outPt2 repeat ...
            do
            {
                result = PointInPolygon(outPt.pt, outPt2, UseFullInt64Range);
                outPt = outPt.next;
            }
            while (result && outPt != outPt1);
            return result;
        }
开发者ID:caomw,项目名称:elementdiscovery,代码行数:23,代码来源:clipper.cs

示例8: ReversePolyPtLinks

      //------------------------------------------------------------------------------

      private void ReversePolyPtLinks(OutPt pp)
      {
          if (pp == null) return;
          OutPt pp1;
          OutPt pp2;
          pp1 = pp;
          do
          {
              pp2 = pp1.Next;
              pp1.Next = pp1.Prev;
              pp1.Prev = pp2;
              pp1 = pp2;
          } while (pp1 != pp);
      }
开发者ID:CharlesTaylor95,项目名称:clipper,代码行数:16,代码来源:clipper.cs

示例9: DupOutPt

      //------------------------------------------------------------------------------

      OutPt DupOutPt(OutPt outPt, bool InsertAfter)
      {
        OutPt result = new OutPt();
        result.Pt = outPt.Pt;
        result.Idx = outPt.Idx;
        if (InsertAfter)
        {
          result.Next = outPt.Next;
          result.Prev = outPt;
          outPt.Next.Prev = result;
          outPt.Next = result;
        } 
        else
        {
          result.Prev = outPt.Prev;
          result.Next = outPt;
          outPt.Prev.Next = result;
          outPt.Prev = result;
        }
        return result;
      }
开发者ID:CharlesTaylor95,项目名称:clipper,代码行数:23,代码来源:clipper.cs

示例10: AddOutPt

      //------------------------------------------------------------------------------

      private OutPt AddOutPt(TEdge e, IntPoint pt)
      {
        bool ToFront = (e.Side == EdgeSide.esLeft);
        if(  e.OutIdx < 0 )
        {
          OutRec outRec = CreateOutRec();
          outRec.IsOpen = (e.WindDelta == 0);
          OutPt newOp = new OutPt();
          outRec.Pts = newOp;
          newOp.Idx = outRec.Idx;
          newOp.Pt = pt;
          newOp.Next = newOp;
          newOp.Prev = newOp;
          if (!outRec.IsOpen)
            SetHoleState(e, outRec);
#if use_xyz
          if (pt == e.Bot)
            newOp.Pt = e.Bot;
          else if (pt == e.Top)
            newOp.Pt = e.Top;
          else
            SetZ(ref newOp.Pt, e);
#endif
          e.OutIdx = outRec.Idx; //nb: do this after SetZ !
          return newOp;
        } else
        {
          OutRec outRec = m_PolyOuts[e.OutIdx];
          //OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most'
          OutPt op = outRec.Pts;
          if (ToFront && pt == op.Pt) return op;
          else if (!ToFront && pt == op.Prev.Pt) return op.Prev;

          OutPt newOp = new OutPt();
          newOp.Idx = outRec.Idx;
          newOp.Pt = pt;
          newOp.Next = op;
          newOp.Prev = op.Prev;
          newOp.Prev.Next = newOp;
          op.Prev = newOp;
          if (ToFront) outRec.Pts = newOp;
#if use_xyz
          if (pt == e.Bot)
            newOp.Pt = e.Bot;
          else if (pt == e.Top)
            newOp.Pt = e.Top;
          else
            SetZ(ref newOp.Pt, e);
#endif
          return newOp;
        }
      }
开发者ID:CharlesTaylor95,项目名称:clipper,代码行数:54,代码来源:clipper.cs

示例11: FirstIsBottomPt

      //---------------------------------------------------------------------------

      private bool FirstIsBottomPt(OutPt btmPt1, OutPt btmPt2)
      {
        OutPt p = btmPt1.Prev;
        while ((p.Pt == btmPt1.Pt) && (p != btmPt1)) p = p.Prev;
        double dx1p = Math.Abs(GetDx(btmPt1.Pt, p.Pt));
        p = btmPt1.Next;
        while ((p.Pt == btmPt1.Pt) && (p != btmPt1)) p = p.Next;
        double dx1n = Math.Abs(GetDx(btmPt1.Pt, p.Pt));

        p = btmPt2.Prev;
        while ((p.Pt == btmPt2.Pt) && (p != btmPt2)) p = p.Prev;
        double dx2p = Math.Abs(GetDx(btmPt2.Pt, p.Pt));
        p = btmPt2.Next;
        while ((p.Pt == btmPt2.Pt) && (p != btmPt2)) p = p.Next;
        double dx2n = Math.Abs(GetDx(btmPt2.Pt, p.Pt));
        return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n);
      }
开发者ID:CharlesTaylor95,项目名称:clipper,代码行数:19,代码来源:clipper.cs

示例12: AddGhostJoin

      //------------------------------------------------------------------------------

      private void AddGhostJoin(OutPt Op, IntPoint OffPt)
      {
        Join j = new Join();
        j.OutPt1 = Op;
        j.OffPt = OffPt;
        m_GhostJoins.Add(j);
      }
开发者ID:CharlesTaylor95,项目名称:clipper,代码行数:9,代码来源:clipper.cs

示例13: AddJoin

      //------------------------------------------------------------------------------

      private void AddJoin(OutPt Op1, OutPt Op2, IntPoint OffPt)
      {
        Join j = new Join();
        j.OutPt1 = Op1;
        j.OutPt2 = Op2;
        j.OffPt = OffPt;
        m_Joins.Add(j);
      }
开发者ID:CharlesTaylor95,项目名称:clipper,代码行数:10,代码来源:clipper.cs

示例14: AddOutPt

        //------------------------------------------------------------------------------
        private void AddOutPt(TEdge e, IntPoint pt)
        {
            bool ToFront = (e.side == EdgeSide.esLeft);
              if(  e.outIdx < 0 )
              {
              OutRec outRec = CreateOutRec();
              m_PolyOuts.Add(outRec);
              outRec.idx = m_PolyOuts.Count -1;
              e.outIdx = outRec.idx;
              OutPt op = new OutPt();
              outRec.pts = op;
              outRec.bottomPt = op;
              op.pt = pt;
              op.idx = outRec.idx;
              op.next = op;
              op.prev = op;
              SetHoleState(e, outRec);
              } else
              {
              OutRec outRec = m_PolyOuts[e.outIdx];
              OutPt op = outRec.pts, op2, opBot;
              if (ToFront && PointsEqual(pt, op.pt) ||
                  (!ToFront && PointsEqual(pt, op.prev.pt))) return;

              if ((e.side | outRec.sides) != outRec.sides)
              {
                  //check for 'rounding' artefacts ...
                  if (outRec.sides == EdgeSide.esNeither && pt.Y == op.pt.Y)
                      if (ToFront)
                      {
                          if (pt.X == op.pt.X + 1) return;    //ie wrong side of bottomPt
                      }
                      else if (pt.X == op.pt.X - 1) return; //ie wrong side of bottomPt

                  outRec.sides = (EdgeSide)(outRec.sides | e.side);
                  if (outRec.sides == EdgeSide.esBoth)
                  {
                    //A vertex from each side has now been added.
                    //Vertices of one side of an output polygon are quite commonly close to
                    //or even 'touching' edges of the other side of the output polygon.
                    //Very occasionally vertices from one side can 'cross' an edge on the
                    //the other side. The distance 'crossed' is always less that a unit
                    //and is purely an artefact of coordinate rounding. Nevertheless, this
                    //results in very tiny self-intersections. Because of the way
                    //orientation is calculated, even tiny self-intersections can cause
                    //the Orientation function to return the wrong result. Therefore, it's
                    //important to ensure that any self-intersections close to BottomPt are
                    //detected and removed before orientation is assigned.

                    if (ToFront)
                    {
                      opBot = outRec.pts;
                      op2 = opBot.next; //op2 == right side
                      if (opBot.pt.Y != op2.pt.Y && opBot.pt.Y != pt.Y &&
                        ((opBot.pt.X - pt.X) / (opBot.pt.Y - pt.Y) <
                        (opBot.pt.X - op2.pt.X) / (opBot.pt.Y - op2.pt.Y)))
                          outRec.bottomFlag = opBot;
                    }
                    else
                    {
                      opBot = outRec.pts.prev;
                      op2 = opBot.next; //op2 == left side
                      if (opBot.pt.Y != op2.pt.Y && opBot.pt.Y != pt.Y &&
                        ((opBot.pt.X - pt.X) / (opBot.pt.Y - pt.Y) >
                        (opBot.pt.X - op2.pt.X) / (opBot.pt.Y - op2.pt.Y)))
                          outRec.bottomFlag = opBot;
                    }
                  }
              }

              op2 = new OutPt();
              op2.pt = pt;
              op2.idx = outRec.idx;
              if (op2.pt.Y == outRec.bottomPt.pt.Y &&
                op2.pt.X < outRec.bottomPt.pt.X)
                  outRec.bottomPt = op2;
              op2.next = op;
              op2.prev = op.prev;
              op2.prev.next = op2;
              op.prev = op2;
              if (ToFront) outRec.pts = op2;
              }
        }
开发者ID:yolpsoftware,项目名称:Polygon-Clipper,代码行数:84,代码来源:clipper.cs

示例15: FirstIsBottomPt

        //---------------------------------------------------------------------------

        private bool FirstIsBottomPt(OutPt btmPt1, OutPt btmPt2)
        {
          OutPt p = btmPt1.prev;
          while (PointsEqual(p.pt, btmPt1.pt) && (p != btmPt1)) p = p.prev;
          double dx1p = Math.Abs(GetDx(btmPt1.pt, p.pt));
          p = btmPt1.next;
          while (PointsEqual(p.pt, btmPt1.pt) && (p != btmPt1)) p = p.next;
          double dx1n = Math.Abs(GetDx(btmPt1.pt, p.pt));

          p = btmPt2.prev;
          while (PointsEqual(p.pt, btmPt2.pt) && (p != btmPt2)) p = p.prev;
          double dx2p = Math.Abs(GetDx(btmPt2.pt, p.pt));
          p = btmPt2.next;
          while (PointsEqual(p.pt, btmPt2.pt) && (p != btmPt2)) p = p.next;
          double dx2n = Math.Abs(GetDx(btmPt2.pt, p.pt));
          return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n);
        }
开发者ID:caomw,项目名称:elementdiscovery,代码行数:19,代码来源:clipper.cs


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