Example #1
0
        public IGeometry CreateGeometry(double radius, IPolyline polyline, double qdgc, double zdgc)
        {
            IPointCollection pointCollection = CreatePointCollectionForCircle(radius);
            IVector3D        pVectorZ        = new Vector3DClass();

            pVectorZ.SetComponents(0, 0, 1);
            IConstructMultiPatch patch = new MultiPatchClass();
            IZAware zAware             = pointCollection as IZAware;

            if (zAware == null)
            {
                return(null);
            }
            zAware.ZAware = true;
            // 依据管线长度拉伸
            patch.ConstructExtrude(polyline.Length, pointCollection as IGeometry);
            // 依据管线角度旋转
            IVector3D pVector3D = new Vector3DClass();

            pVector3D.SetComponents(polyline.ToPoint.X - polyline.FromPoint.X, polyline.ToPoint.Y - polyline.FromPoint.Y, zdgc - qdgc);
            double       rotateAngle = Math.Acos(pVector3D.ZComponent / pVector3D.Magnitude);
            IVector3D    vectorAxis  = pVectorZ.CrossProduct(pVector3D) as IVector3D;
            ITransform3D transform3D = patch as ITransform3D;

            transform3D.RotateVector3D(vectorAxis, rotateAngle);
            // 平移到指定位置
            transform3D.Move3D(polyline.FromPoint.X, polyline.FromPoint.Y, qdgc);
            return(patch as IGeometry);
        }
Example #2
0
        public override IGeometry CreateGeometry()
        {
            IPointCollection pointCollection = new PolygonClass();
            IZAware          zAware          = pointCollection as IZAware;

            zAware.ZAware = true;

            IPoint point = new PointClass();

            point.X = -_width / 2;
            point.Y = -_height / 2;
            point.Z = 0;
            pointCollection.AddPoint(point);

            point   = new PointClass();
            point.X = -_width / 2;
            point.Y = _height / 2;
            point.Z = 0;
            pointCollection.AddPoint(point);

            point   = new PointClass();
            point.X = _width / 2;
            point.Y = _height / 2;
            point.Z = 0;
            pointCollection.AddPoint(point);

            point   = new PointClass();
            point.X = _width / 2;
            point.Y = -_height / 2;
            point.Z = 0;
            pointCollection.AddPoint(point);
            ((IPolygon)pointCollection).Close();

            IConstructMultiPatch patch = new MultiPatchClass();

            patch.ConstructExtrude(_polyline.Length, pointCollection as IGeometry);

            IVector3D vectorZ = new Vector3DClass();

            vectorZ.SetComponents(0, 0, 1);
            IVector3D vector3D = new Vector3DClass();

            vector3D.SetComponents(_polyline.ToPoint.X - _polyline.FromPoint.X, _polyline.ToPoint.Y - _polyline.FromPoint.Y, _zdgc - _qdgc);
            double    rotateAngle = Math.Acos(vector3D.ZComponent / vector3D.Magnitude);
            IVector3D vectorAxis  = vectorZ.CrossProduct(vector3D) as IVector3D;

            ITransform3D transform3D = patch as ITransform3D;

            transform3D.RotateVector3D(vectorAxis, rotateAngle);
            transform3D.Move3D(_polyline.FromPoint.X, _polyline.FromPoint.Y, _qdgc);
            return(patch as IGeometry);
        }
Example #3
0
        public override IGeometry CreateGeometry()
        {
            IPointCollection pointCollection = new PolygonClass();
            IZAware          zAware          = pointCollection as IZAware;

            zAware.ZAware = true;

            IPoint point = new PointClass();

            point.X = -_width / 2;
            point.Y = -_length / 2;
            point.Z = 0;
            pointCollection.AddPoint(point);

            point   = new PointClass();
            point.X = -_width / 2;
            point.Y = _length / 2;
            point.Z = 0;
            pointCollection.AddPoint(point);

            point   = new PointClass();
            point.X = _width / 2;
            point.Y = _length / 2;
            point.Z = 0;
            pointCollection.AddPoint(point);

            point   = new PointClass();
            point.X = _width / 2;
            point.Y = -_length / 2;
            point.Z = 0;
            pointCollection.AddPoint(point);

            ((IPolygon)pointCollection).Close();

            IConstructMultiPatch patch = new MultiPatchClass();

            patch.ConstructExtrude(0 - _depth, pointCollection as IGeometry);
            ITransform3D transform3D = patch as ITransform3D;
            IVector3D    vector3D    = ConstructVector3D(0, 0, 1);

            transform3D.RotateVector3D(vector3D, _radian);
            transform3D.Move3D(_x, _y, _z);
            return(patch as IGeometry);
        }
Example #4
0
 private void RotateGeometry(IMarker3DSymbol pSymbol, IVector3D pAxis, double dDegree)
 {
     if ((pAxis != null) && (dDegree != 0.0))
     {
         IMarker3DPlacement placement = pSymbol as IMarker3DPlacement;
         IGeometry          shape     = placement.Shape;
         IEnvelope          envelope  = shape.Envelope;
         IPoint             point     = new PointClass
         {
             X = envelope.XMin + (envelope.XMax - envelope.XMin),
             Y = envelope.YMin + (envelope.YMax - envelope.YMin),
             Z = envelope.ZMin + (envelope.ZMax - envelope.ZMin)
         };
         double       rotationAngle = this.DegreesToRadians(dDegree);
         ITransform3D transformd    = shape as ITransform3D;
         transformd.Move3D(-point.X, -point.Y, -point.Z);
         transformd.RotateVector3D(pAxis, rotationAngle);
         transformd.Move3D(point.X, point.Y, point.Z);
     }
 }
Example #5
0
        private static void DrawEnd(IGraphicsContainer3D endGraphicsContainer3D, IPoint endPoint, IVector3D axisOfRotationVector3D, double degreesOfRotation, IColor endColor, double endRadius)
        {
            IGeometry endGeometry = Vector3DExamples.GetExample2();

            ITransform3D transform3D = endGeometry as ITransform3D;

            IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0);

            transform3D.Scale3D(originPoint, endRadius, endRadius, 2 * endRadius);

            if (degreesOfRotation != 0)
            {
                double angleOfRotationInRadians = GeometryUtilities.GetRadians(degreesOfRotation);

                transform3D.RotateVector3D(axisOfRotationVector3D, angleOfRotationInRadians);
            }

            transform3D.Move3D(endPoint.X - originPoint.X, endPoint.Y - originPoint.Y, endPoint.Z - originPoint.Z);

            GraphicsLayer3DUtilities.AddMultiPatchToGraphicsLayer3D(endGraphicsContainer3D, endGeometry, endColor);
        }
Example #6
0
        public static IGeometry GetExample3()
        {
            const double DegreesOfRotation = 45;

            //Transform3D: Cylinder Rotated Around An Axis Via RotateVector3D()

            IGeometry geometry = Vector3DExamples.GetExample3();

            //Construct A Vector3D Corresponding To The Desired Axis Of Rotation

            IVector3D axisOfRotationVector3D = GeometryUtilities.ConstructVector3D(0, 10, 0);

            //Obtain Angle Of Rotation In Radians

            double angleOfRotationInRadians = GeometryUtilities.GetRadians(DegreesOfRotation);

            ITransform3D transform3D = geometry as ITransform3D;

            transform3D.RotateVector3D(axisOfRotationVector3D, angleOfRotationInRadians);

            return(geometry);
        }
Example #7
0
        public static IGeometry GetExample4()
        {
            const double XScale            = 0.5;
            const double YScale            = 0.5;
            const double ZScale            = 2;
            const double XOffset           = -5;
            const double YOffset           = -5;
            const double ZOffset           = -8;
            const double DegreesOfRotation = 90;

            //Transform3D: Cylinder Scaled, Rotated, Repositioned Via Move3D(), Scale3D(), RotateVector3D()

            IGeometry geometry = Vector3DExamples.GetExample3();

            ITransform3D transform3D = geometry as ITransform3D;

            //Stretch The Cylinder So It Looks Like A Tube

            IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0);

            transform3D.Scale3D(originPoint, XScale, YScale, ZScale);

            //Rotate The Cylinder So It Lies On Its Side

            IVector3D axisOfRotationVector3D = GeometryUtilities.ConstructVector3D(0, 10, 0);

            double angleOfRotationInRadians = GeometryUtilities.GetRadians(DegreesOfRotation);

            transform3D.RotateVector3D(axisOfRotationVector3D, angleOfRotationInRadians);

            //Reposition The Cylinder So It Is Located Underground

            transform3D.Move3D(XOffset, YOffset, ZOffset);

            return(geometry);
        }
Example #8
0
        public void CreateFeature()
        {
            //移动放缩矢量箭头
            IVector3D VerticalVector = Material.ConstructVector3D(0, 0, 1);
            IPoint    originPoint    = Material.ConstructPoint3D(0, 0, 0);

            Material.MakeZAware(originPoint as IGeometry);

            //创建所有要素
            for (int i = 0; i < VectorModel.TinCount; i++)
            {
                IFeature BarycentreFeature = BarycentreFeatureClass.CreateFeature();
                BarycentreFeature.Shape = BARYCENTRE[i];
                int index1 = BarycentreFeature.Fields.FindField("X");
                BarycentreFeature.set_Value(index1, BARYCENTRE[i].X);
                int index2 = BarycentreFeature.Fields.FindField("Y");
                BarycentreFeature.set_Value(index2, BARYCENTRE[i].Y);
                int index3 = BarycentreFeature.Fields.FindField("Z");
                BarycentreFeature.set_Value(index3, BARYCENTRE[i].Z);
                int index4 = BarycentreFeature.Fields.FindField("Probability");
                BarycentreFeature.set_Value(index4, 0.95 - (0.9 / 49) * i);
                BarycentreFeature.Store();

                if (i == 0)
                {
                    Ctxt.WriteLine("GOCAD VSet" + "\r\n"
                                   + "HEADER" + "\r\n"
                                   + "{name: Borehole}" + "\r\n"
                                   + "GOCAD_ORIGINAL_COORDINATE_SYSTEM\nNAME" + "\r\n"
                                   + "PROJECTION Unknown" + "\r\n"
                                   + "DATUM Unknown" + "\r\n"
                                   + "AXIS_NAME X Y Z" + "\r\n"
                                   + "AXIS_UNIT m m m" + "\r\n"
                                   + "ZPOSITIVE Elevation" + "\r\n"
                                   + "END_ORIGINAL_COORDINATE_SYSTEM" + "\r\n"
                                   + "PROPERTIES P" + "\r\n"
                                   + "PROP_LEGAL_RANGES **none**  **none**" + "\r\n"
                                   + "NO_DATA_VALUES -99999" + "\r\n"
                                   + "PROPERTY_CLASSES p" + "\r\n"
                                   + "PROPERTY_KINDS \"Real Number\"" + "\r\n"
                                   + "PROPERTY_SUBCLASSES QUANTITY Float" + "\r\n"
                                   + "ESIZES 1" + "\r\n"
                                   + "UNITS unitless" + "\r\n"
                                   + "PROPERTY_CLASS_HEADER X {" + "\r\n" + "kind: X" + "\r\n" + "unit: m" + "\r\n" + "pclip: 99}" + "\r\n"
                                   + "PROPERTY_CLASS_HEADER Y {" + "\r\n" + "kind: Y" + "\r\n" + "unit: m" + "\r\n" + "pclip: 99}" + "\r\n"
                                   + "PROPERTY_CLASS_HEADER Z {" + "\r\n" + "kind: Depth\nunit: m" + "\r\n" + "is_z: on" + "\r\n" + "pclip: 99}" + "\r\n"
                                   + "PROPERTY_CLASS_HEADER p {" + "\r\n" + "kind: Real Number" + "\r\n" + "unit: unitless" + "\r\n" + "pclip: 99}" + "\r\n"
                                   );
                }
                Ctxt.Write("PVRTX " + i + " ");
                Ctxt.Write(BARYCENTRE[i].X + " ");
                Ctxt.Write(BARYCENTRE[i].Y + " ");
                Ctxt.Write(BARYCENTRE[i].Z + " ");
                if (i == VectorModel.TinCount - 1)
                {
                    Ctxt.WriteLine("0.5" + " ");
                }
                else
                {
                    Ctxt.WriteLine(0.95 - (0.9 / 49) * i + " ");
                }

                if (i == VectorModel.TinCount - 1)
                {
                    Ctxt.Write("END");
                    Ctxt.Close();
                }


                ////创建重力线
                IFeature VectorFeature = GravityVectorFeatureClass.CreateFeature();
                IPoint   endPoint      = new PointClass();
                Material.MakeZAware(endPoint as IGeometry);
                //根据体积设置末端点
                endPoint.X = BARYCENTRE[i].X;
                endPoint.Y = BARYCENTRE[i].Y;
                endPoint.Z = BARYCENTRE[i].Z - VOLUME[i] * gLength;                                        //
                //添加两点构成向量
                IPointCollection VectorPointCollection = new PolylineClass();
                Material.MakeZAware(VectorPointCollection as IGeometry);
                VectorPointCollection.AddPoint(BARYCENTRE[i], ref _missing, ref _missing);
                VectorPointCollection.AddPoint(endPoint, ref _missing, ref _missing);
                VectorFeature.Shape = VectorPointCollection as IGeometry;
                int index5 = VectorFeature.Fields.FindField("Gravity");
                VectorFeature.set_Value(index5, VOLUME[i]);
                int index6 = VectorFeature.Fields.FindField("Probability");
                VectorFeature.set_Value(index6, 0.95 - (0.9 / 49) * i);
                VectorFeature.Store();

                ////添加矢量箭头
                //得到重力矢量
                IVector3D Gvector     = Material.CreateVector3DTwoPoints(endPoint, BARYCENTRE[i]);
                IGeometry Arrow       = Material.GetArrow();
                double    Inclination = Gvector.Inclination;
                //计算与竖向矢量夹角
                double       degreesOfRotation = Math.Acos((Gvector.DotProduct(VerticalVector)) / ((Gvector.Magnitude) * (VerticalVector.Magnitude)));
                ITransform3D transform3D       = Arrow as ITransform3D;
                //放缩
                transform3D.Scale3D(originPoint, XScale, YScale, ZScale);
                //转动
                if (degreesOfRotation != 0)
                {
                    double    angleOfRotationInRadians = degreesOfRotation;
                    IVector3D axisOfRotationVector3D   = new Vector3DClass();
                    axisOfRotationVector3D.XComponent = 1;
                    axisOfRotationVector3D.YComponent = 0;
                    axisOfRotationVector3D.ZComponent = 0;
                    transform3D.RotateVector3D(axisOfRotationVector3D, angleOfRotationInRadians);
                }
                //平移
                if (endPoint.IsEmpty)
                {
                    continue;
                }
                transform3D.Move3D(endPoint.X - originPoint.X, endPoint.Y - originPoint.Y, endPoint.Z - originPoint.Z);
                IFeature ArrowFeature = ArrowFeatureClass.CreateFeature();
                ArrowFeature.Shape = Arrow as IMultiPatch;
                int index7 = ArrowFeature.Fields.FindField("Probability");
                ArrowFeature.set_Value(index7, 0.95 - (0.9 / 49) * i);
                ArrowFeature.Store();
                //墙壁
                IFeature EnCloseFeature = EncloseFeatureClass[i].CreateFeature();
                EnCloseFeature.Shape = multiPatchGeometryCollection[i] as IMultiPatch;
                int index17 = EnCloseFeature.Fields.FindField("Probability");
                EnCloseFeature.set_Value(index7, 0.95 - (0.9 / 49) * i);
                EnCloseFeature.Store();

                Vtxt.WriteLine(VOLUME[i]);
                if (i == VectorModel.TinCount - 1)
                {
                    Vtxt.Close();
                }
            }
        }
Example #9
0
        public static IGeometry GetExample13()
        {
            const double CircleDegrees         = 360.0;
            const int    CircleDivisions       = 36;
            const double VectorComponentOffset = 0.0000001;
            const double CircleRadius          = 3.0;
            const double BaseZ = 0.0;
            const double RotationAngleInDegrees = 89.9;

            //Extrusion: 3D Circle Polyline Extruded Along 3D Vector Via ConstructExtrudeRelative()

            IPointCollection pathPointCollection = new PathClass();

            IGeometry pathGeometry = pathPointCollection as IGeometry;

            GeometryUtilities.MakeZAware(pathGeometry);

            IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0);

            IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10);

            IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10);

            lowerAxisVector3D.XComponent += VectorComponentOffset;

            IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D;

            normalVector3D.Magnitude = CircleRadius;

            double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions);

            for (int i = 0; i < CircleDivisions; i++)
            {
                normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D);

                IPoint vertexPoint = GeometryUtilities.ConstructPoint3D(originPoint.X + normalVector3D.XComponent,
                                                                        originPoint.Y + normalVector3D.YComponent,
                                                                        BaseZ);

                pathPointCollection.AddPoint(vertexPoint, ref _missing, ref _missing);
            }

            pathPointCollection.AddPoint(pathPointCollection.get_Point(0), ref _missing, ref _missing);

            //Rotate Geometry

            IVector3D rotationAxisVector3D = GeometryUtilities.ConstructVector3D(0, 10, 0);

            ITransform3D transform3D = pathGeometry as ITransform3D;

            transform3D.RotateVector3D(rotationAxisVector3D, GeometryUtilities.GetRadians(RotationAngleInDegrees));

            //Construct Polyline From Path Vertices

            IGeometry polylineGeometry = new PolylineClass();

            GeometryUtilities.MakeZAware(polylineGeometry);

            IPointCollection polylinePointCollection = polylineGeometry as IPointCollection;

            for (int i = 0; i < pathPointCollection.PointCount; i++)
            {
                polylinePointCollection.AddPoint(pathPointCollection.get_Point(i), ref _missing, ref _missing);
            }

            ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator;

            topologicalOperator.Simplify();

            //Define Vector To Extrude Along

            IVector3D extrusionVector3D = GeometryUtilities.ConstructVector3D(10, 0, 5);

            //Perform Extrusion

            IConstructMultiPatch constructMultiPatch = new MultiPatchClass();

            constructMultiPatch.ConstructExtrudeRelative(extrusionVector3D, polylineGeometry);

            return(constructMultiPatch as IGeometry);
        }