Example #1
0
        public void _updateSegment()
        {
            if (m_nextSegmentIndex < 0 || m_nextSegmentIndex >= m_segmentCount)
            {
                throw new System.IndexOutOfRangeException();
            }
            m_currentSegmentIndex = m_nextSegmentIndex;
            int startVertexIndex = GetStartPointIndex();

            m_parent._verifyAllStreams();
            com.epl.geometry.AttributeStreamOfInt8 segFlagStream = m_parent.GetSegmentFlagsStreamRef();
            int segFlag = com.epl.geometry.SegmentFlags.enumLineSeg;

            if (segFlagStream != null)
            {
                segFlag = (segFlagStream.Read(startVertexIndex) & com.epl.geometry.SegmentFlags.enumSegmentMask);
            }
            com.epl.geometry.VertexDescription vertexDescr = m_parent.GetDescription();
            switch (segFlag)
            {
            case com.epl.geometry.SegmentFlags.enumLineSeg:
            {
                if (m_line == null)
                {
                    m_line = new com.epl.geometry.Line();
                }
                m_currentSegment = (com.epl.geometry.Line)m_line;
                break;
            }

            case com.epl.geometry.SegmentFlags.enumBezierSeg:
            {
                throw com.epl.geometry.GeometryException.GeometryInternalError();
            }

            case com.epl.geometry.SegmentFlags.enumArcSeg:
            {
                // break;
                throw com.epl.geometry.GeometryException.GeometryInternalError();
            }

            default:
            {
                // break;
                throw com.epl.geometry.GeometryException.GeometryInternalError();
            }
            }
            m_currentSegment.AssignVertexDescription(vertexDescr);
            int endVertexIndex = GetEndPointIndex();

            m_parent.GetXY(startVertexIndex, m_dummyPoint);
            m_currentSegment.SetStartXY(m_dummyPoint);
            m_parent.GetXY(endVertexIndex, m_dummyPoint);
            m_currentSegment.SetEndXY(m_dummyPoint);
            for (int i = 1, nattr = vertexDescr.GetAttributeCount(); i < nattr; i++)
            {
                int semantics = vertexDescr.GetSemantics(i);
                int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                for (int ord = 0; ord < ncomp; ord++)
                {
                    double vs = m_parent.GetAttributeAsDbl(semantics, startVertexIndex, ord);
                    m_currentSegment.SetStartAttribute(semantics, ord, vs);
                    double ve = m_parent.GetAttributeAsDbl(semantics, endVertexIndex, ord);
                    m_currentSegment.SetEndAttribute(semantics, ord, ve);
                }
            }
        }
Example #2
0
 public override com.epl.geometry.VertexDescription GetDescription()
 {
     return(m_impl.GetDescription());
 }
Example #3
0
 internal static com.epl.geometry.MultiPoint CalculatePolylineBoundary_(object impl, com.epl.geometry.ProgressTracker progress_tracker, bool only_check_non_empty_boundary, bool[] not_empty)
 {
     if (not_empty != null)
     {
         not_empty[0] = false;
     }
     com.epl.geometry.MultiPathImpl mpImpl = (com.epl.geometry.MultiPathImpl)impl;
     com.epl.geometry.MultiPoint    dst    = null;
     if (!only_check_non_empty_boundary)
     {
         dst = new com.epl.geometry.MultiPoint(mpImpl.GetDescription());
     }
     if (!mpImpl.IsEmpty())
     {
         com.epl.geometry.AttributeStreamOfInt32 indices = new com.epl.geometry.AttributeStreamOfInt32(0);
         indices.Reserve(mpImpl.GetPathCount() * 2);
         for (int ipath = 0, nPathCount = mpImpl.GetPathCount(); ipath < nPathCount; ipath++)
         {
             int path_size = mpImpl.GetPathSize(ipath);
             if (path_size > 0 && !mpImpl.IsClosedPathInXYPlane(ipath))
             {
                 // closed
                 // paths
                 // of
                 // polyline
                 // do
                 // not
                 // contribute
                 // to
                 // the
                 // boundary.
                 int start = mpImpl.GetPathStart(ipath);
                 indices.Add(start);
                 int end = mpImpl.GetPathEnd(ipath) - 1;
                 indices.Add(end);
             }
         }
         if (indices.Size() > 0)
         {
             com.epl.geometry.BucketSort           sorter = new com.epl.geometry.BucketSort();
             com.epl.geometry.AttributeStreamOfDbl xy     = (com.epl.geometry.AttributeStreamOfDbl)(mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION));
             sorter.Sort(indices, 0, indices.Size(), new com.epl.geometry.Boundary.MultiPathImplBoundarySorter(xy));
             com.epl.geometry.Point2D ptPrev = new com.epl.geometry.Point2D();
             xy.Read(2 * indices.Get(0), ptPrev);
             int ind     = 0;
             int counter = 1;
             com.epl.geometry.Point   point = new com.epl.geometry.Point();
             com.epl.geometry.Point2D pt    = new com.epl.geometry.Point2D();
             for (int i = 1, n = indices.Size(); i < n; i++)
             {
                 xy.Read(2 * indices.Get(i), pt);
                 if (pt.IsEqual(ptPrev))
                 {
                     if (indices.Get(ind) > indices.Get(i))
                     {
                         // remove duplicate point
                         indices.Set(ind, com.epl.geometry.NumberUtils.IntMax());
                         ind = i;
                     }
                     else
                     {
                         // just for the heck of it, have the first
                         // point in the order to be added to the
                         // boundary.
                         indices.Set(i, com.epl.geometry.NumberUtils.IntMax());
                     }
                     counter++;
                 }
                 else
                 {
                     if ((counter & 1) == 0)
                     {
                         // remove boundary point
                         indices.Set(ind, com.epl.geometry.NumberUtils.IntMax());
                     }
                     else
                     {
                         if (only_check_non_empty_boundary)
                         {
                             if (not_empty != null)
                             {
                                 not_empty[0] = true;
                             }
                             return(null);
                         }
                     }
                     ptPrev.SetCoords(pt);
                     ind     = i;
                     counter = 1;
                 }
             }
             if ((counter & 1) == 0)
             {
                 // remove the point
                 indices.Set(ind, com.epl.geometry.NumberUtils.IntMax());
             }
             else
             {
                 if (only_check_non_empty_boundary)
                 {
                     if (not_empty != null)
                     {
                         not_empty[0] = true;
                     }
                     return(null);
                 }
             }
             if (!only_check_non_empty_boundary)
             {
                 indices.Sort(0, indices.Size());
                 for (int i_1 = 0, n = indices.Size(); i_1 < n; i_1++)
                 {
                     if (indices.Get(i_1) == com.epl.geometry.NumberUtils.IntMax())
                     {
                         break;
                     }
                     mpImpl.GetPointByVal(indices.Get(i_1), point);
                     dst.Add(point);
                 }
             }
         }
     }
     if (only_check_non_empty_boundary)
     {
         return(null);
     }
     return(dst);
 }