コード例 #1
0
        public DataToTopography(Document document, List <List <XYZ> > contours, double interpolationLength = 10, double proximityTolerance = 5)
        {
            Dictionary <string, XYZ> dict = new Dictionary <string, XYZ>();
            int counter = 0;

            foreach (List <XYZ> cntr in contours)
            {
                ProcessPolygon processedContour = new ProcessPolygon(cntr);
                processedContour.LoadEdgeLengths();
                processedContour.RemoveClosePoints(proximityTolerance);
                processedContour.Interpolate(interpolationLength);
                processedContour.LoadEdgeLengths();
                foreach (XYZ item in processedContour.ProcessedPolygon)
                {
                    string key = item.X.ToString() + item.Y.ToString();
                    try
                    {
                        dict.Add(key, item);
                    }
                    catch (Exception)
                    {
                        //MessageBox.Show(er.Message);
                        counter++;
                    }
                }
            }
            this.NumberOfFailedPoints = counter;
            List <XYZ> pnts = new List <XYZ>();

            foreach (var item in dict.Keys)
            {
                XYZ pn;
                if (dict.TryGetValue(item, out pn))
                {
                    pnts.Add(pn);
                }
            }
            using (Transaction createTopography = new Transaction(document))
            {
                createTopography.Start("Create Topography");
                this.Topography = TopographySurface.Create(document, pnts);
                createTopography.Commit();
            }
        }
コード例 #2
0
        public List <ElementId> Visualize(Document doc, Polygon polygon, double elevation, int exponent)
        {
            List <XYZ> points = new List <XYZ>();

            points = this.Polygon2XYZList(polygon, elevation, exponent);
            ProcessPolygon processedContour = new ProcessPolygon(points, true);

            processedContour.LoadEdgeLengths();
            //MessageBox.Show(string.Format("Minimum distance is {0} \n Maximum distance is {1}", processedContour.MinimumEdgeLength.ToString(), processedContour.MaximumEdgeLength.ToString()));
            return(processedContour.Visualize(doc));
        }