Commits

Robin Harper committed 8b8706c

removed the inner points collection and replaced the calling code with calls to PointsInNode(); Shrank binary file size by 200mb

Comments (0)

Files changed (13)

 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		BuildVersion_UseGlobalSettings = True
+		BuildVersion_AssemblyInfoFilename = AstarPath\Properties\AssemblyInfo.cs
+	EndGlobalSection
 EndGlobal

AstarPath/AstarPath.csproj

     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <ProjectExtensions>
+    <VisualStudio>
+      <UserProperties BuildVersion_UseGlobalSettings="True" />
+    </VisualStudio>
+  </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

AstarPath/AstarPathfinder.cs

 //==================================================================================================
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Drawing;
 using System.Linq;
         {
             var opened = new Grid();
             var closed = new Grid();
-            var start = Grid.FirstOrDefault(t => t.PointsInsideGrid.Contains(inputStart));
-            var goal = Grid.FirstOrDefault(t => t.PointsInsideGrid.Contains(inputGoal));
+            var start = Grid.FirstOrDefault(t => t.PointsInNode().Contains(inputStart));
+            var goal = Grid.FirstOrDefault(t => t.PointsInNode().Contains(inputGoal));
 
             if (start != null && goal != null)
             {

AstarPath/Grid.cs

 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
 
 namespace AstarPath
 {
+    [Serializable]
     public class Grid : List<GridNode>
     {
-        public Grid() : base()
-        {
-            
-        }
+        public Grid() { }
 
-        public Grid(List<GridNode> list)
-            : base(list)
-        {
-        }
+        public Grid(IEnumerable<GridNode> list) : base(list) { }
 
         public GridNode this[int x, int y]
         {
             get 
             {
-                if (this.Count > 0)
+                if (Count > 0)
                 {
                     if (x >= 0 && y >= 0)
                     {
                                  where node.X == x && node.Y == y
                                  select node);
 
-                        if (n != null && n.Count() > 0)
+                        if (n.Count() > 0)
                         {
                             return n.First();
                         }
             return Merge(left, right);
         }
 
-        private Grid Merge(List<GridNode> left, List<GridNode> right)
+        private static Grid Merge(List<GridNode> left, List<GridNode> right)
         {
             var result = new Grid();
 

AstarPath/GridNode.cs

 //
 //==================================================================================================
 
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
 using System.Drawing;
 
 namespace AstarPath
 {
+    [Serializable]
     public class GridNode
     {
-        public readonly List<Point> PointsInsideGrid;
         public readonly Rectangle GridBorder;
-        public readonly Location Center = null;
-        public readonly GridNode Parent = null;
+        public readonly Location Center;
+        public readonly GridNode Parent;
 
         // Grid block x, y. Not related to pixel coordinates
         public readonly int X;
             Y = GridBorder.Y;
             PixelX = Center.x;
             PixelY = Center.y;
-
-            PointsInsideGrid = CalculateInnerPoints();
         }
 
         /// <summary>
         /// a given point exists within this grid block.
         /// </summary>
         /// <returns></returns>
-        private List<Point> CalculateInnerPoints()
+        public List<Point> PointsInNode()
         {
             var points = new List<Point>();
             var tp = PathfinderUtilities.GetTopLeftPoint(PixelX, PixelY, Size);
-            var TopLeftPixelX = tp.X;
-            var TopLeftPixelY = tp.Y;
-            for(int x = 0; x < GridBorder.Width; x++)
+            var topLeftPixelX = tp.X;
+            var topLeftPixelY = tp.Y;
+            for(var x = 0; x < GridBorder.Width; x++)
             {
-                for (int y = 0; y < GridBorder.Height; y++)
+                for (var y = 0; y < GridBorder.Height; y++)
                 {
-                    var localPoint = new Point(TopLeftPixelX + x, TopLeftPixelY + y);
+                    var localPoint = new Point(topLeftPixelX + x, topLeftPixelY + y);
 
-                    if ((localPoint.X < TopLeftPixelX + Size) && 
-                        (localPoint.Y < TopLeftPixelY + Size))
+                    if ((localPoint.X < topLeftPixelX + Size) && 
+                        (localPoint.Y < topLeftPixelY + Size))
                     {
                         points.Add(localPoint);
                     }
                     // equal
                     return 0;
                 }
-                else
-                {
-                    // b was greater than a
-                    return -1;
-                }
+                // b was greater than a
+                return -1;
             }
-            else
+
+            if (b == null)
             {
-                if (b == null)
-                {
-                    // a was greater than b
-                    return 1;
-                }
-                else
-                {
-                    int retval = a.Center.f.CompareTo(b.Center.f);
+                // a was greater than b
+                return 1;
+            }
+            var retval = a.Center.f.CompareTo(b.Center.f);
 
-                    if (retval != 0)
-                    {
-                        return retval;
-                    }
-                    else
-                    {
-                        // in the event the costs are the same return them as 
-                        // equal so that we don't end up moving low cost items
-                        // to far away from the top
-                        return 0;
-                    }
-                }
-            }
+            return retval != 0 ? retval : 0;
+            // in the event the costs are the same return them as 
+            // equal so that we don't end up moving low cost items
+            // to far away from the top
         }
 
         public static List<GridNode> MergeSort(List<GridNode> list)

AstarPath/Location.cs

 //==================================================================================================
 
 using System;
-using System.Collections.Generic;
 using System.Drawing;
-using System.Text;
-using System.ComponentModel;
 
 namespace AstarPath
 {
     [Serializable]
-    public class Location : INotifyPropertyChanged
+    public class Location
     {
-        public string _name;
-        public string Name
-        {
-            get { return _name; }
-            private set
-            {
-                _name = value;
-                OnPropertyChanged("Name");
-            }
-        }
+        public string Name { get; private set; }
 
         /// <summary>
         /// 
         public Location(Point p)
         {
             Name = "";
-            this.x = p.X;
-            this.y = p.Y;
+            x = p.X;
+            y = p.Y;
         }
 
         /// <summary>
         /// <returns></returns>
         public Point ToPoint()
         {
-            return new Point(this.x, this.y);
-        }
-
-        #region INotifyPropertyChanged Members
-
-        public event PropertyChangedEventHandler PropertyChanged;
-
-        #endregion
-
-        // Create the OnPropertyChanged method to raise the event
-        protected void OnPropertyChanged(string name)
-        {
-            PropertyChangedEventHandler handler = PropertyChanged;
-            if (handler != null)
-            {
-                handler(this, new PropertyChangedEventArgs(name));
-            }
+            return new Point(x, y);
         }
     }
 }

AstarPath/PathfinderUtilities.cs

 //==================================================================================================
 
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Drawing;
 
 
         #endregion
 
-        public static object locker = new object();
-
         /// <summary>
         /// Searches the actual bitmap object at position x, y and
         /// using GetPixel returns a color and then verifies it against
                 {
                     var rectangle = new Rectangle(xcounter, ycounter, gridSize, gridSize);
                     // set default obstacle status to false
-                    var cp = PathfinderUtilities.GetActualCenterPoint(x, y, gridSize);
+                    var cp = GetActualCenterPoint(x, y, gridSize);
                     var center = new Location(cp);
                     //var gridBlock = new GridNode(rectangle, x, y, false);
                     var gridBlock = new GridNode(rectangle, false, center, null);
 
                     // now check each inner point of the block
                     // and evaluate if it is infact an obstacle or not
-                    foreach (var innerPoint in gridBlock.PointsInsideGrid)
+                    foreach (var innerPoint in gridBlock.PointsInNode())
                     {
                         if (innerPoint.X >= 0 && innerPoint.X < inputMap.Width)
                         {
             var _grid = new Grid();
 
             int ycounter = 0;
-            int xcounter = 0;
 
             for (int y = 0; y < map.Height; y += gridSize)
             {
-                xcounter = 0;
+                int xcounter = 0;
                 for (int x = 0; x < map.Width; x += gridSize)
                 {
                     var rectangle = new Rectangle(xcounter, ycounter, gridSize, gridSize);
                     // set default obstacle status to false
-                    var cp = PathfinderUtilities.GetActualCenterPoint(x, y, gridSize);
+                    var cp = GetActualCenterPoint(x, y, gridSize);
                     var center = new Location(cp);
                     var gridBlock = new GridNode(rectangle, false, center, null);
 
         {
             for(int i = 0; i < grid.Count; i++)
             {
-                foreach (var p in grid[i].PointsInsideGrid)
+                foreach (var p in grid[i].PointsInNode())
                 {
                     if (p.X >= 0 && p.X < map.Width)
                     {

AstarPath/Properties/AssemblyInfo.cs

 //==================================================================================================
 
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // General Information about an assembly is controlled through the following 
 [assembly: AssemblyTitle("AstarPath")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyCompany("Zerklabs")]
 [assembly: AssemblyProduct("AstarPath")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyCopyright("Copyright © Robin Harper 2010")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.2010.1230.17")]
+[assembly: AssemblyFileVersion("1.2010.1230.17")]

AstarPath/bin/Debug/AstarPath.dll

Binary file added.

PathTester/PathTester.csproj

     </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <ProjectExtensions>
+    <VisualStudio>
+      <UserProperties BuildVersion_UseGlobalSettings="True" />
+    </VisualStudio>
+  </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

PathTester/Properties/AssemblyInfo.cs

 [assembly: AssemblyTitle("PathTester")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyCompany("Zerklabs")]
 [assembly: AssemblyProduct("PathTester")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyCopyright("Copyright © Robn Harper 2010")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.2010.1230.8")]
+[assembly: AssemblyFileVersion("1.2010.1230.8")]

PathTester/bin/Debug/AstarPath.dll

Binary file added.

PathTester/bin/Debug/PathTester.exe.config

+<?xml version="1.0"?>
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>