コード例 #1
0
        public void Populate(IObjectWithPathAndChildren source)
        {
            if (name.isNullOrEmpty())
            {
                name = source.name;
            }

            var allChilren = source.getAllChildren();

            foreach (var item in allChilren)
            {
                Int32 ChildrenCount = 0;
                foreach (var citem in item)
                {
                    ChildrenCount++;
                }

                ChildrenCountRange.Learn(ChildrenCount);

                if (ChildrenCount == 0)
                {
                    LeafNodes++;
                    LeafLevelRange.Learn(item.level);
                }
                LevelRange.Learn(item.level);
            }

            TotalCount = allChilren.Count;
        }
コード例 #2
0
 public void Validate_string(ushort from, ushort to, string input)
 {
     var value = new LevelRange(input);
     Assert.Equal(from, value.From);
     Assert.Equal(to, value.To);
     Assert.True(value.IsValid);
 }
コード例 #3
0
 public void GuardClause()
 {
     Assert.Throws<ArgumentNullException>(() =>
     {
         var value = new LevelRange(null);
     });
 }
コード例 #4
0
 public void New_instance_is_from_0_to_max()
 {
     var value = new LevelRange();
     Assert.True(value.From == 0);
     Assert.True(value.To == ushort.MaxValue);
     Assert.True(value.IsValid);
 }
コード例 #5
0
 public void Invalid_initialization_throws_ArgumentException(string range)
 {
     Assert.Throws<ArgumentException>(() =>
     {
         var value = new LevelRange(range);
     });
 }
コード例 #6
0
        private void CopyFromRow(int destRowIndex, DataGridViewRow source)
        {
            BraveFaithRange destRowBFR     = (BraveFaithRange)destRowIndex;
            LevelRange      destRowLR      = (LevelRange)destRowIndex;
            int             sourceRowIndex = source.Index;

            foreach (BraveFaithNeutral bfn in (BraveFaithNeutral[])Enum.GetValues(typeof(BraveFaithNeutral)))
            {
                //var thisTuple = Tuple.From(bfn, destRowBFR);

                //if (braveBonuses.ContainsKey(thisTuple))
                if (destRowIndex < faithBonusesFirstRow)
                {
                    braveBonuses[bfn, destRowBFR] = (byte)(dataGridView1[(int)bfn, sourceRowIndex].Value);
                }
                else if (destRowIndex < levelBonusesFirstRow)
                //if (faithBonuses.ContainsKey(thisTuple))
                {
                    faithBonuses[bfn, destRowBFR - faithBonusesFirstRow] = (byte)(dataGridView1[(int)bfn, sourceRowIndex].Value);
                }
                else
                //if (levelBonuses.ContainsKey(Tuple.From(bfn, destRowLR)))
                {
                    levelBonuses[bfn, destRowLR - levelBonusesFirstRow] = (byte)(dataGridView1[(int)bfn, sourceRowIndex].Value);
                }
            }
        }
コード例 #7
0
		public FetchPlan(string fetchPlan)
		{
			if (fetchPlan == null)
			{
				throw new ArgumentNullException(nameof(fetchPlan));
			}

			var match = fetchPlanRegex.Match(fetchPlan);
			if (!match.Success)
			{
				throw new ArgumentException($"Invalid fetch plan text format. '{fetchPlan}'", nameof(fetchPlan));
			}

			var dic = new Dictionary<string, DepthLevel>();
			var group1 = match.Groups[1];
			if (group1.Success)
			{
				Levels = new LevelRange(group1.Value);
			}
			var group2 = match.Groups[2];
			var group3 = match.Groups[3];
			dic.Add(group2.Value, new DepthLevel(short.Parse(group3.Value)));
			var group4 = match.Groups[4];
			var group5 = match.Groups[5];
			if (group4.Success && group5.Success)
			{
				for (int i = 0; i < group4.Captures.Count; i++)
				{
					var key = group4.Captures[i].Value;
					var value = group5.Captures[i].Value;
					dic.Add(key, new DepthLevel(short.Parse(value)));
				}
			}
			DepthMapping = dic;
		}
コード例 #8
0
ファイル: Utitlity.cs プロジェクト: tosha1983/atdi.ua
        static public LevelRange CalcLevelRange(double minValue, double maxValue)
        {
            var result = new LevelRange
            {
                MaxValue = maxValue >= 0 ? Convert.ToDouble(Math.Truncate((decimal)maxValue / 10) * 10 + 10) : Convert.ToDouble(Math.Truncate((decimal)maxValue / 10) * 10),
                MinValue = minValue >= 0 ? Convert.ToDouble(Math.Truncate((decimal)minValue / 10) * 10) : Convert.ToDouble(Math.Truncate((decimal)minValue / 10) * 10 - 10)
            };

            return(result);
        }
コード例 #9
0
        private LevelRangePolygon[] assignLevelsToPolygons(double surfaceMin, double surfaceMax, IList <Polygon> polygons, List <Triangle> triangles, double[] zLevels, BoundingRectangle bounds)
        {
            List <Feature> triangularFeatures = new List <Feature>();

            foreach (Triangle t in triangles)
            {
                Polygon p = new Polygon(new ICoordinate[]
                {
                    new Coordinate3D(t.Cell1.DataPoint.Values()),
                    new Coordinate3D(t.Cell2.DataPoint.Values()),
                    new Coordinate3D(t.Cell3.DataPoint.Values())
                });
                triangularFeatures.Add(new Feature(p));
            }

            triangles = null;

            KDTree index = new KDTree(bounds);

            index.MinObjectCount     = 10;
            index.MaxDepth           = 20;
            index.BoxSquareThreshold = index.IndexedSpace.Width * index.IndexedSpace.Height / 10000;

            index.Build(triangularFeatures);

            LevelRange[] ranges = getRanges(surfaceMin, surfaceMax, zLevels);

            List <LevelRangePolygon> result = new List <LevelRangePolygon>();

            foreach (Polygon p in polygons)
            {
                ICoordinate    c = p.PointOnSurface();
                List <Feature> t = new List <Feature>();
                index.QueryObjectsContainingPoint(c, t);
                foreach (Feature f in t)
                {
                    Polygon triangle = f.Polygon;
                    if (triangle.ContainsPoint(c))
                    {
                        double z =
                            getZ(c,
                                 new Coordinate3D(triangle.Contours[0].Vertices[0].Values()),
                                 new Coordinate3D(triangle.Contours[0].Vertices[1].Values()),
                                 new Coordinate3D(triangle.Contours[0].Vertices[2].Values()));

                        LevelRange range = getRange(z, ranges);
                        result.Add(new LevelRangePolygon(range, p));
                        break;
                    }
                }
            }

            return(result.ToArray());
        }
コード例 #10
0
        public StructureGraphInformation GetDifference(StructureGraphInformation other)
        {
            StructureGraphInformation output = new StructureGraphInformation();

            output.name       = "Difference between " + name + " and " + other.name;
            output.InputCount = InputCount - other.InputCount;
            output.TotalCount = TotalCount - other.TotalCount;
            output.LeafNodes  = LeafNodes - other.LeafNodes;

            output.LevelRange         = LevelRange.GetDifference(other.LevelRange);
            output.LeafLevelRange     = LeafLevelRange.GetDifference(other.LeafLevelRange);
            output.ChildrenCountRange = ChildrenCountRange.GetDifference(other.ChildrenCountRange);

            return(output);
        }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the MapAround.Geometry.Extensions.Surfaces.IsolineBuilder.LevelRangePolygon
 /// </summary>
 /// <param name="range">A range</param>
 /// <param name="polygon">A polygon</param>
 public LevelRangePolygon(LevelRange range, Polygon polygon)
 {
     Range = range;
     Polygon = polygon;
 }
コード例 #12
0
 public void Validate_from_to(ushort from, ushort to, string expected)
 {
     var value = new LevelRange(from, to).ToString();
     Assert.Equal(expected, value);
 }
コード例 #13
0
 public void New_instance_ToString_returns_star()
 {
     var value = new LevelRange().ToString();
     var expected = "*";
     Assert.Equal(expected, value);
 }
コード例 #14
0
 public void Invalid_range()
 {
     var value = new LevelRange(5, 1);
     Assert.False(value.IsValid);
 }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the MapAround.Geometry.Extensions.Surfaces.IsolineBuilder.LevelRangePolygon
 /// </summary>
 /// <param name="range">A range</param>
 /// <param name="polygon">A polygon</param>
 public LevelRangePolygon(LevelRange range, Polygon polygon)
 {
     Range   = range;
     Polygon = polygon;
 }