Ejemplo n.º 1
0
        private void btnConstructCircle_Click(object sender, EventArgs e)
        {
            if (gfactory == null)
                gfactory = new GeometryFactory();

            // 圆心
            point = gfactory.CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint;
            point.X = 5; point.Y = 6; point.Z = 7;
            // 半径
            double dRadius = 10.0;
            // 垂直于圆所在平面的单位法向量,用于确定圆在三维空间的位置
            // 如果只有圆心和半径那么在三维空间内有无数的这样的圆组成一个球
            IVector3 vNormal = new Vector3();
            vNormal.Set(0, 0, 1);
            circle = gfactory.CreateGeometry(gviGeometryType.gviGeometryCircle, gviVertexAttribute.gviVertexAttributeZ) as ICircle;
            circle.ConstructCenterAndRadius(point, dRadius, vNormal);
            if (circle == null)
                return;

            Circle geo = new Circle();
            // Geometry属性
            geo.Dimension = circle.Dimension;
            if (circle.Envelope != null)
            {
                geo.MaxX = circle.Envelope.MaxX;
                geo.MaxY = circle.Envelope.MaxY;
                geo.MaxZ = circle.Envelope.MaxZ;
                geo.MinX = circle.Envelope.MinX;
                geo.MinY = circle.Envelope.MinY;
                geo.MinZ = circle.Envelope.MinZ;
            }
            geo.GeometryType = circle.GeometryType;
            geo.IsEmpty = circle.IsEmpty;
            geo.IsValid = circle.IsValid;
            geo.VertexAttribute = circle.VertexAttribute;
            geo.HasId = circle.HasId();
            geo.HasM = circle.HasM();
            geo.HasZ = circle.HasZ();
            // Curve属性
            geo.IsClosed = circle.IsClosed;
            geo.Length = circle.Length;
            if (circle.StartPoint != null)
            {
                geo.StartPointX = circle.StartPoint.X;
                geo.StartPointY = circle.StartPoint.Y;
                geo.StartPointZ = circle.StartPoint.Z;
            }
            if (circle.EndPoint != null)
            {
                geo.EndPointX = circle.EndPoint.X;
                geo.EndPointY = circle.EndPoint.Y;
                geo.EndPointZ = circle.EndPoint.Z;
            }
            // Circle属性
            if (circle.CenterPoint != null)
            {
                geo.CenterPointX = circle.CenterPoint.X;
                geo.CenterPointY = circle.CenterPoint.Y;
                geo.CenterPointZ = circle.CenterPoint.Z;
            }
            geo.Radius = circle.Radius;
            if (circle.Normal != null)
            {
                geo.NormalX = circle.Normal.X;
                geo.NormalY = circle.Normal.Y;
                geo.NormalZ = circle.Normal.Z;
            }

            this.propertyGrid1.SelectedObject = geo;
        }