Ejemplo n.º 1
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();
                }
            }
        }