public override void GetPointByVal(int index, com.epl.geometry.Point dst)
 {
     if (index < 0 || index >= m_pointCount)
     {
         // TODO
         throw new com.epl.geometry.GeometryException("index out of bounds");
     }
     // _ASSERT(!IsEmpty());
     // _ASSERT(m_vertexAttributes != null);
     _verifyAllStreams();
     com.epl.geometry.Point outPoint = dst;
     outPoint.AssignVertexDescription(m_description);
     if (outPoint.IsEmpty())
     {
         outPoint._setToDefault();
     }
     for (int attributeIndex = 0; attributeIndex < m_description.GetAttributeCount(); attributeIndex++)
     {
         // fix semantics
         int semantics = m_description._getSemanticsImpl(attributeIndex);
         // VertexDescription.getComponentCount(semantics);
         for (int icomp = 0, ncomp = com.epl.geometry.VertexDescription.GetComponentCount(semantics); icomp < ncomp; icomp++)
         {
             double v = m_vertexAttributes[attributeIndex].ReadAsDbl(ncomp * index + icomp);
             outPoint.SetAttribute(semantics, icomp, v);
         }
     }
 }
 internal virtual void _interpolateTwoVertices(int vertex1, int vertex2, double f, com.epl.geometry.Point outPoint)
 {
     if (vertex1 < 0 || vertex1 >= m_pointCount)
     {
         throw new com.epl.geometry.GeometryException("index out of bounds.");
     }
     if (vertex2 < 0 || vertex2 >= m_pointCount)
     {
         throw new com.epl.geometry.GeometryException("index out of bounds.");
     }
     // _ASSERT(!IsEmpty());
     // _ASSERT(m_vertexAttributes != NULLPTR);
     _verifyAllStreams();
     outPoint.AssignVertexDescription(m_description);
     if (outPoint.IsEmpty())
     {
         outPoint._setToDefault();
     }
     for (int attributeIndex = 0; attributeIndex < m_description.GetAttributeCount(); attributeIndex++)
     {
         int semantics = m_description._getSemanticsImpl(attributeIndex);
         for (int icomp = 0, ncomp = com.epl.geometry.VertexDescription.GetComponentCount(semantics); icomp < ncomp; icomp++)
         {
             double v1 = m_vertexAttributes[attributeIndex].ReadAsDbl(ncomp * vertex1 + icomp);
             double v2 = m_vertexAttributes[attributeIndex].ReadAsDbl(ncomp * vertex2 + icomp);
             outPoint.SetAttribute(semantics, icomp, com.epl.geometry.MathUtils.Lerp(v1, v2, f));
         }
     }
 }
Exemplo n.º 3
0
 //This is a writeReplace class for Point
 /// <exception cref="java.io.ObjectStreamException"/>
 public virtual object ReadResolve()
 {
     com.epl.geometry.Point point = null;
     try
     {
         com.epl.geometry.VertexDescription vd = com.epl.geometry.VertexDescriptionDesignerImpl.GetVertexDescription(descriptionBitMask);
         point = new com.epl.geometry.Point(vd);
         if (attribs != null)
         {
             point.SetXY(attribs[0], attribs[1]);
             int index = 2;
             for (int i = 1, n = vd.GetAttributeCount(); i < n; i++)
             {
                 int semantics = vd.GetSemantics(i);
                 int comps     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                 for (int ord = 0; ord < comps; ord++)
                 {
                     point.SetAttribute(semantics, ord, attribs[index++]);
                 }
             }
         }
     }
     catch (System.Exception)
     {
         throw new System.IO.InvalidDataException("Cannot read geometry from stream");
     }
     return(point);
 }
Exemplo n.º 4
0
 public virtual void TestPoint()
 {
     com.epl.geometry.Point pt = new com.epl.geometry.Point();
     pt.SetXY(100, 200);
     NUnit.Framework.Assert.IsFalse(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsTrue(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(double.IsNaN(pt.GetM()));
     pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 13);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 0);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 0, 11);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.ID);
     NUnit.Framework.Assert.IsTrue(pt.GetID() == 0);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.ID, 0, 1);
     NUnit.Framework.Assert.IsTrue(pt.GetID() == 1);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.DropAttribute(com.epl.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsTrue(pt.GetID() == 1);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11);
     NUnit.Framework.Assert.IsFalse(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     com.epl.geometry.Point pt1 = new com.epl.geometry.Point();
     NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
     NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID));
     pt1.MergeVertexDescription(pt.GetDescription());
     NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
     NUnit.Framework.Assert.IsTrue(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID));
 }
Exemplo n.º 5
0
 internal virtual void QueryCoord(double t, com.epl.geometry.Point point)
 {
     point.AssignVertexDescription(m_description);
     point.SetXY(GetCoord2D(t));
     for (int iattrib = 1, nattrib = m_description.GetAttributeCount(); iattrib < nattrib; iattrib++)
     {
         int semantics = m_description._getSemanticsImpl(iattrib);
         int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
         for (int iord = 0; iord < ncomp; iord++)
         {
             double value = GetAttributeAsDbl(t, semantics, iord);
             point.SetAttribute(semantics, iord, value);
         }
     }
 }
Exemplo n.º 6
0
 private void _get(int endPoint, com.epl.geometry.Point outPoint)
 {
     if (IsEmptyImpl())
     {
         throw new com.epl.geometry.GeometryException("empty geometry");
     }
     // ._setToDefault();
     outPoint.AssignVertexDescription(m_description);
     if (outPoint.IsEmptyImpl())
     {
         outPoint._setToDefault();
     }
     for (int attributeIndex = 0; attributeIndex < m_description.GetAttributeCount(); attributeIndex++)
     {
         int semantics = m_description._getSemanticsImpl(attributeIndex);
         for (int icomp = 0, ncomp = com.epl.geometry.VertexDescription.GetComponentCount(semantics); icomp < ncomp; icomp++)
         {
             double v = _getAttributeAsDbl(endPoint, semantics, icomp);
             outPoint.SetAttribute(semantics, icomp, v);
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>Returns the center point of the envelope.</summary>
        /// <returns>The center point of the envelope.</returns>
        public virtual com.epl.geometry.Point GetCenter()
        {
            com.epl.geometry.Point pointOut = new com.epl.geometry.Point(m_description);
            if (IsEmpty())
            {
                return(pointOut);
            }
            int nattrib = m_description.GetAttributeCount();

            for (int i = 1; i < nattrib; i++)
            {
                int semantics = m_description._getSemanticsImpl(i);
                int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                for (int iord = 0; iord < ncomp; iord++)
                {
                    double v = 0.5 * (_getAttributeAsDbl(0, semantics, iord) + _getAttributeAsDbl(1, semantics, iord));
                    pointOut.SetAttribute(semantics, iord, v);
                }
            }
            pointOut.SetXY(m_envelope.GetCenterX(), m_envelope.GetCenterY());
            return(pointOut);
        }
Exemplo n.º 8
0
        public virtual void GetCenter(com.epl.geometry.Point point_out)
        {
            point_out.AssignVertexDescription(m_description);
            if (IsEmpty())
            {
                point_out.SetEmpty();
                return;
            }
            int nattrib = m_description.GetAttributeCount();

            for (int i = 1; i < nattrib; i++)
            {
                int semantics = m_description.GetSemantics(i);
                int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                for (int iord = 0; iord < ncomp; iord++)
                {
                    double v = 0.5 * (GetAttributeAsDblImpl_(0, semantics, iord) + GetAttributeAsDblImpl_(1, semantics, iord));
                    point_out.SetAttribute(semantics, iord, v);
                }
            }
            point_out.SetXY(m_envelope.GetCenter());
        }
 // ////////////////// METHODS To REMOVE ///////////////////////
 public override com.epl.geometry.Point GetPoint(int index)
 {
     if (index < 0 || index >= m_pointCount)
     {
         throw new System.IndexOutOfRangeException();
     }
     _verifyAllStreams();
     com.epl.geometry.Point outPoint = new com.epl.geometry.Point();
     outPoint.AssignVertexDescription(m_description);
     if (outPoint.IsEmpty())
     {
         outPoint._setToDefault();
     }
     for (int attributeIndex = 0; attributeIndex < m_description.GetAttributeCount(); attributeIndex++)
     {
         int semantics = m_description.GetSemantics(attributeIndex);
         for (int icomp = 0, ncomp = com.epl.geometry.VertexDescription.GetComponentCount(semantics); icomp < ncomp; icomp++)
         {
             double v = m_vertexAttributes[attributeIndex].ReadAsDbl(ncomp * index + icomp);
             outPoint.SetAttribute(semantics, icomp, v);
         }
     }
     return(outPoint);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Sets the point's coordinates to the coordinates of the envelope at the
        /// given corner.
        /// </summary>
        /// <param name="index">
        /// The index of the envelope's corners from 0 to 3.
        /// <p>
        /// 0 = lower left corner
        /// <p>
        /// 1 = top-left corner
        /// <p>
        /// 2 = top right corner
        /// <p>
        /// 3 = bottom right corner
        /// </param>
        /// <param name="ptDst">
        /// The point whose coordinates are used to set the envelope's
        /// coordinate at a specified corner.
        /// </param>
        public virtual void QueryCornerByVal(int index, com.epl.geometry.Point ptDst)
        {
            ptDst.AssignVertexDescription(m_description);
            int nattrib = GetDescription().GetAttributeCount() - 1;

            switch (index)
            {
            case 0:
            {
                for (int i = 0; i < nattrib; i++)
                {
                    int semantics = m_description.GetSemantics(i);
                    int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                    for (int iord = 0; iord < ncomp; iord++)
                    {
                        ptDst.SetAttribute(semantics, iord, _getAttributeAsDbl(0, semantics, iord));
                    }
                }
                ptDst.SetXY(m_envelope.xmin, m_envelope.ymin);
                return;
            }

            case 1:
            {
                for (int i = 0; i < nattrib; i++)
                {
                    int semantics = m_description.GetSemantics(i);
                    int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                    for (int iord = 0; iord < ncomp; iord++)
                    {
                        ptDst.SetAttribute(semantics, iord, _getAttributeAsDbl(1, semantics, iord));
                    }
                }
                ptDst.SetXY(m_envelope.xmin, m_envelope.ymax);
                return;
            }

            case 2:
            {
                for (int i = 0; i < nattrib; i++)
                {
                    int semantics = m_description.GetSemantics(i);
                    int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                    for (int iord = 0; iord < ncomp; iord++)
                    {
                        ptDst.SetAttribute(semantics, iord, _getAttributeAsDbl(0, semantics, iord));
                    }
                }
                ptDst.SetXY(m_envelope.xmax, m_envelope.ymax);
                return;
            }

            case 3:
            {
                for (int i = 0; i < nattrib; i++)
                {
                    int semantics = m_description.GetSemantics(i);
                    int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                    for (int iord = 0; iord < ncomp; iord++)
                    {
                        ptDst.SetAttribute(semantics, iord, _getAttributeAsDbl(1, semantics, iord));
                    }
                }
                ptDst.SetXY(m_envelope.xmax, m_envelope.ymin);
                return;
            }

            default:
            {
                throw new System.IndexOutOfRangeException();
            }
            }
        }