Exemple #1
0
        //根据创建的点要素做tin
        public void CreatTINs()
        {
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

            Workspace = workspaceFactory.OpenFromFile(workspacepath, 0);
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)Workspace;

            //new tin 的范围
            tin = new TinClass();
            tin.Init(tinpath);
            IEnvelope EnvO = tin.Extent;
            IEnvelope Env  = new EnvelopeClass();

            Env.XMax = EnvO.XMax + 10;
            Env.YMax = EnvO.YMax + 10;
            Env.ZMax = EnvO.ZMax + 100;
            Env.XMin = EnvO.XMin + 10;
            Env.YMin = EnvO.YMin + 10;
            Env.ZMin = EnvO.ZMin + 100;

            // Instantiate a new empty TIN.
            ITinEdit[] TinEdit   = new ITinEdit[SurfaceCount + 1];
            object     overwrite = true;

            for (int i = 0; i < SurfaceCount + 1; i++)
            {
                TinEdit[i] = new TinClass();
                TinEdit[i].InitNew(Env);
                TinEdit[i].SaveAs(OutTinPath + "_" + i, ref overwrite);
            }

            IFeatureClass[] ISOpointFeatureClass = new IFeatureClass[SurfaceCount + 1];
            for (int i = 0; i < SurfaceCount + 1; i++)
            {
                ISOpointFeatureClass[i] = featureWorkspace.OpenFeatureClass("Node_" + i);
                IGeometryCollection MultipointGeometryCollection = new MultipointClass();
                MakeZAware(MultipointGeometryCollection as IGeometry);
                for (int p = 0; p < NodeCount - 4; p++)
                {
                    IPoint onePoint = ISOpointFeatureClass[i].GetFeature(p + 1).Shape as IPoint;
                    MakeZAware(onePoint);
                    MultipointGeometryCollection.AddGeometry(onePoint);
                }
                (TinEdit[i] as ITinEdit2).SetToConstrainedDelaunay();
                TinEdit[i].AddShapeZ(MultipointGeometryCollection as IGeometry, esriTinSurfaceType.esriTinMassPoint, 0, _missing);
                TinEdit[i].Save();
            }
        }
Exemple #2
0
        public void GetTinData(int TinID)
        {
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

            Workspace = workspaceFactory.OpenFromFile(workSpacePath, 0);
            // Open an existing TIN, edit the following path as appropriate.
            tinU = new TinClass();
            tinU.Init(UpSurfacePath + TinID);
            tinD = new TinClass();
            tinD.Init(DownSurfacePath + TinID);
            tinUmax = new TinClass();
            tinUmax.Init(maxUpSurfacePath);
            tinDmin = new TinClass();
            tinDmin.Init(minDownSurfacePath);
            IEnvelope EnvelopeU = tinUmax.Extent;
            IEnvelope EnvelopeD = tinDmin.Extent;
            double    MZMax     = EnvelopeU.ZMax;
            double    MZMin     = EnvelopeD.ZMin;

            XMin       = EnvelopeU.XMin;
            XMax       = EnvelopeU.XMax;
            YMin       = EnvelopeU.YMin;
            YMax       = EnvelopeU.YMax;
            ZMax       = MZMax + AddBoundry;
            ZMin       = MZMin - AddBoundry;
            RowCount   = (int)((XMax - XMin + 0.5 * RasterSize) / RasterSize) + 1;
            Llength    = XMax - XMin;
            Wlength    = YMax - YMin;
            Hlength    = ZMax - ZMin;
            BoxVolume  = Llength * Wlength * Hlength;
            NodeCount  = tinDmin.NodeCount;
            orderNodeU = new ITinNode[NodeCount];
            orderNodeD = new ITinNode[NodeCount];
            TINID      = TinID;
        }
Exemple #3
0
        public void CreateNode()
        {
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

            Workspace = workspaceFactory.OpenFromFile(workspacepath, 0);
            // Open an existing TIN, edit the following path as appropriate.
            tin = new TinClass();
            tin.Init(tinpath);
            Borehole = new StreamWriter(boreholepath);
            //得到和tin网直接相关的数据
            IEnvelope Envelope = tin.Extent;

            XMin = Envelope.XMin;
            XMax = Envelope.XMax;
            YMin = Envelope.YMin;
            YMax = Envelope.YMax;
            //列数
            RowCount  = (int)((XMax - XMin + 0.5 * RasterSize) / RasterSize) + 1;
            NodeCount = tin.NodeCount;
            //钻孔总点数
            DenseCount = (int)HalfBoreLength * 2 * density;

            //点间距
            Double Dstep = 1.0 / density;

            OSNodes  = new ITinNode[NodeCount];
            OSPoints = new IPoint[NodeCount];
            for (int i = 4; i < NodeCount; i++)
            {
                //得到按序排列的初始曲面节点
                ITinNode OSNode = tin.GetNode(i + 1);
                int      v      = (int)((OSNode.X - (XMin - (RasterSize / 2))) / RasterSize) + RowCount * (int)((OSNode.Y - (YMin - (RasterSize / 2))) / (RasterSize));
                OSNodes[v]  = OSNode;
                OSPoints[v] = new PointClass();
                MakeZAware(OSPoints[v]);
                OSNode.QueryAsPoint(OSPoints[v]);
            }

            //一根中心在原点的密集点柱
            double Zinitial = 0;
            double Zlow     = Zinitial - HalfBoreLength;

            DensePoints = new IPoint[DenseCount];
            for (int j = 0; j < DenseCount; j++)
            {
                double thisZ         = Zlow + j * Dstep;
                IPoint OneDensePoint = new PointClass();
                MakeZAware(OneDensePoint);
                OneDensePoint.X = 0;
                OneDensePoint.Y = 0;
                OneDensePoint.Z = thisZ;
                DensePoints[j]  = OneDensePoint;
            }

            //得到揭露Fd的钻孔编号的索引
            string[] XYLine = File.ReadAllLines(XYpath);
            BoreCount = XYLine.Length;
            BoreXY    = new double[BoreCount, 2];
            int l = 0;

            for (int j = 0; j < BoreCount; j++)
            {
                string   m      = XYLine[j];
                string   M      = new System.Text.RegularExpressions.Regex("[\\s]+").Replace(m, " ");
                string[] mArray = M.Split(' ');
                BoreXY[j, 0] = Convert.ToDouble(mArray[2]);
                BoreXY[j, 1] = Convert.ToDouble(mArray[1]);
                string ChangA = Convert.ToString(mArray[0]);
                //if ((ChangA == SelectBore1) || (ChangA == SelectBore2) || (ChangA == SelectBore3))
                if ((ChangA == SelectBore1))
                {
                    boreLocationChangeA[l] = j;
                    l++;
                }
            }
        }