Esempio n. 1
0
        /// <summary>
        /// Creates ag3.DCurve from a geometry
        /// </summary>
        /// <param name="curve"> this curve</param>
        /// <param name="geom"> the OGR geometry to ue as ths source</param>
        /// <param name="crs"> the crs to u for the DCurve3 DEFAULT map default projections or EPG:4326 if none</param>
        /// <returns></returns>
        public static DCurve3 FromGeometry(this DCurve3 curve, Geometry geom, SpatialReference crs = null)
        {
            if (geom.GetSpatialReference() == null)
            {
                if (crs != null)
                {
                    geom.AssignSpatialReference(crs);
                }
                else
                {
                    geom.AssignSpatialReference(AppState.instance.projectCrs);
                }
            }
            if (geom.TransformTo(AppState.instance.mapProj) != 0)
            {
                throw new NotSupportedException("projection failed");
            }
            if (geom.Transform(AppState.instance.mapTrans) != 0)
            {
                throw new NotSupportedException("axis change failed");
            }
            int n = geom.GetPointCount();

            Vector3d[] ls = new Vector3d[n];
            for (int i = 0; i < n; i++)
            {
                double[] argout = new double[3];
                geom.GetPoint(i, argout);
                ls[i] = new Vector3d(argout);
            }
            curve.ClearVertices();
            curve.SetVertices(ls);
            curve.Closed = geom.IsRing();
            return(curve);
        }
Esempio n. 2
0
        private void update_axis_vertices(PolyCurveSO curveSO)
        {
            Vector3d[] verticesS   = axisCurveSO.Curve.Vertices.ToArray();
            Frame3f    curveFrameS = axisCurveSO.GetLocalFrame(CoordSpace.SceneCoords);

            for (int k = 0; k < verticesS.Length; ++k)
            {
                verticesS[k] = curveFrameS.FromFrameP((Vector3f)verticesS[k]);
            }
            axisCurve.SetVertices(verticesS);
        }