Changeset 13497 for branches/HeuristicLab.BinPacking
- Timestamp:
- 01/12/16 10:42:58 (9 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 13 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingBin/RectangularPackingBin.cs
r13461 r13497 32 32 33 33 public RectangularPackingBin(int width, int height) : base(width, height) { } 34 public RectangularPackingBin() 35 : base() { 36 37 } 34 public RectangularPackingBin() : base() { } 38 35 39 36 [StorableConstructor] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/CuboidPackingItem.cs
r13461 r13497 29 29 30 30 namespace HeuristicLab.Problems.BinPacking.PackingItem { 31 [Item 31 [Item("CuboidPackingItem", "Represents a cuboidic packing-item for bin-packing problems.")] 32 32 [StorableClass] 33 33 public class CuboidPackingItem : CuboidPackingShape, IPackingItem { 34 [Storable] 35 public CuboidPackingBin TargetBin { get; set; } 34 36 35 public CuboidPackingBin TargetBin { get; set; }37 [Storable] 36 38 public double Weight { get; set; } 39 40 [Storable] 37 41 public int Material { get; set; } 42 38 43 public bool SupportsStacking(IPackingItem other) { 39 44 return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); … … 44 49 protected CuboidPackingItem(CuboidPackingItem original, Cloner cloner) 45 50 : base(original, cloner) { 46 this.Weight = original.Weight; 47 this.Material = original.Material; 51 this.Weight = original.Weight; 52 this.Material = original.Material; 53 this.TargetBin = cloner.Clone(TargetBin); 48 54 } 49 55 public override IDeepCloneable Clone(Cloner cloner) { 50 56 return new CuboidPackingItem(this, cloner); 51 57 } 52 public CuboidPackingItem() : base() { 58 public CuboidPackingItem() 59 : base() { 53 60 } 54 61 55 public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin, double weight, int material) : this(width, height, depth, targetBin) { this.Weight = weight; this.Material = material; } 56 public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin) : base(width, height, depth) { this.TargetBin = new CuboidPackingBin(targetBin.Width, targetBin.Height, targetBin.Depth); } 62 public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin, double weight, int material) 63 : this(width, height, depth, targetBin) { 64 this.Weight = weight; 65 this.Material = material; 66 } 67 68 public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin) 69 : base(width, height, depth) { 70 this.TargetBin = (CuboidPackingBin)targetBin.Clone(); 71 } 57 72 58 73 public void AddTargetBinMeasures(int[] targetBinMeasures) { … … 61 76 62 77 public override string ToString() { 63 return String.Format("CuboidPackingItem ({0}, {1}, {2}; w={3}, m={4})", this.Width, this.Height, this.Depth, this.Weight, this.Material);78 return String.Format("CuboidPackingItem ({0}, {1}, {2}; w={3}, m={4})", this.Width, this.Height, this.Depth, this.Weight, this.Material); 64 79 } 65 80 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/RectangularPackingItem.cs
r13461 r13497 33 33 public class RectangularPackingItem : RectangularPackingShape, IPackingItem { 34 34 35 [Storable] 35 36 public RectangularPackingBin TargetBin { get; set; } 37 38 [Storable] 36 39 public double Weight { get; set; } 40 41 [Storable] 37 42 public int Material { get; set; } 43 38 44 public bool SupportsStacking(IPackingItem other) { 39 45 return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); … … 46 52 this.Weight = original.Weight; 47 53 this.Material = original.Material; 54 this.TargetBin = cloner.Clone(TargetBin); 48 55 } 49 56 public override IDeepCloneable Clone(Cloner cloner) { … … 54 61 } 55 62 56 public RectangularPackingItem(int width, int height, RectangularPackingBin targetBin) : base(width, height) { this.TargetBin = new RectangularPackingBin(targetBin.Width, targetBin.Height); } 63 public RectangularPackingItem(int width, int height, RectangularPackingBin targetBin) 64 : base(width, height) { 65 this.TargetBin = (RectangularPackingBin)targetBin.Clone(); 66 } 57 67 58 68 public void AddTargetBinMeasures(int[] targetBinMeasures) { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
r13461 r13497 21 21 22 22 using System; 23 using System.Diagnostics; 23 24 using HeuristicLab.Problems.BinPacking.Interfaces; 24 25 using HeuristicLab.Core; … … 148 149 149 150 public int CompareTo(object obj) { 150 if (obj.GetType() == this.GetType())151 return this.CompareTo((CuboidPackingShape)obj);152 else return 0;151 var other = (CuboidPackingShape)obj; 152 if (other != null) return CompareTo(other); 153 else throw new ArgumentException(string.Format("Cannot compare with object {0}", obj), "obj"); 153 154 } 154 155 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/PackingShape.cs
r13461 r13497 30 30 [Item("PackingShape", "Represents an abstract shape to describe the measures and the positioning of objects related to bin-packing problems.")] 31 31 [StorableClass] 32 public abstract class PackingShape< D> : Item, IPackingShape33 where D: class, IPackingDimensions {32 public abstract class PackingShape<T> : Item, IPackingShape 33 where T : class, IPackingDimensions { 34 34 public static Type PositionType { 35 get { return typeof( D); }35 get { return typeof(T); } 36 36 } 37 37 38 public abstract bool EnclosesPoint( D myPosition, DcheckedPoint);39 public abstract bool Encloses( D checkedPosition, PackingShape<D> checkedShape);40 public abstract bool Overlaps( D myPosition, D checkedPosition, PackingShape<D> checkedShape);38 public abstract bool EnclosesPoint(T myPosition, T checkedPoint); 39 public abstract bool Encloses(T checkedPosition, PackingShape<T> checkedShape); 40 public abstract bool Overlaps(T myPosition, T checkedPosition, PackingShape<T> checkedShape); 41 41 public abstract void InitializeFromMeasures(int[] measures); 42 42 public abstract int[] ToArray(); 43 43 public abstract int MultipliedMeasures { get; } 44 public abstract DOrigin { get; }44 public abstract T Origin { get; } 45 45 46 46 protected PackingShape(int[] measures) { … … 53 53 [StorableConstructor] 54 54 protected PackingShape(bool deserializing) : base(deserializing) { } 55 protected PackingShape(PackingShape< D> original, Cloner cloner)55 protected PackingShape(PackingShape<T> original, Cloner cloner) 56 56 : base(original, cloner) { 57 57 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs
r13032 r13497 33 33 public abstract class RectangularPackingShape : PackingShape<TwoDimensionalPacking>, IRegularPackingShape, IComparable<RectangularPackingShape> { 34 34 #region Properties 35 /// <summary>36 /// Describes the size on the Y-axis37 /// </summary>38 35 [Storable] 39 36 public int Height { get; set; } 40 /// <summary> 41 /// Describes the size on the X-axis 42 /// </summary> 37 43 38 [Storable] 44 39 public int Width { get; set; } … … 60 55 private bool Encloses(TwoDimensionalPacking checkedPosition, RectangularPackingShape checkedShape) { 61 56 return Encloses(new RectangleDiagonal(this), new RectangleDiagonal(checkedPosition, checkedShape)); 62 } 57 } 63 58 private bool Encloses(RectangleDiagonal r1, RectangleDiagonal r2) { 64 return (r1.x1 <= r2.x1 &&59 return (r1.x1 <= r2.x1 && 65 60 r1.x2 >= r2.x2 && 66 61 r1.y1 <= r2.y1 && … … 71 66 return Overlaps(myPosition, checkedPosition, (RectangularPackingShape)checkedShape); 72 67 } 73 private bool Overlaps(TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPosition, RectangularPackingShape checkedShape) { 74 return Overlaps(new RectangleDiagonal (myPosition, this),new RectangleDiagonal(checkedPosition, checkedShape));68 private bool Overlaps(TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPosition, RectangularPackingShape checkedShape) { 69 return Overlaps(new RectangleDiagonal(myPosition, this), new RectangleDiagonal(checkedPosition, checkedShape)); 75 70 } 76 71 private bool Overlaps(RectangleDiagonal r1, RectangleDiagonal r2) { … … 90 85 #endregion 91 86 92 public RectangularPackingShape(int width, int height) : base () { 87 protected RectangularPackingShape() : base() { } 88 protected RectangularPackingShape(int width, int height) 89 : base() { 93 90 this.Height = height; 94 91 this.Width = width; … … 101 98 this.Height = measures[1]; 102 99 } 103 public override int[] ToArray() { 104 return new int[] { Width, Height }; 105 } 100 106 101 107 102 [StorableConstructor] … … 112 107 this.Height = original.Height; 113 108 } 114 public RectangularPackingShape() : base() {}115 109 116 110 public override string ToString() { … … 124 118 if (result == 0) { 125 119 result = this.Width.CompareTo(other.Width); 126 if (result == 0) 120 if (result == 0) 127 121 result = this.Height.CompareTo(other.Height); 128 122 } … … 131 125 132 126 public int CompareTo(object obj) { 133 if (obj.GetType().Equals(this.GetType()))134 return this.CompareTo((RectangularPackingShape)obj);135 else return 0;127 var other = obj as RectangularPackingShape; 128 if (other != null) return CompareTo(other); 129 else throw new ArgumentException(string.Format("Cannot compare to object {0}", obj), "obj"); 136 130 } 137 131 138 132 #endregion 133 134 public override int[] ToArray() { 135 return new int[] { Width, Height }; 136 } 139 137 140 138 private struct RectangleDiagonal { -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/2D/CenteredContainer2D.cs
r13477 r13497 31 31 private float yScaling; 32 32 private readonly List<PackingItem> packingItems = new List<PackingItem>(); 33 34 //public Vector2 ContainerCenter {35 // get { return new Vector2(controlSize.X / 2, controlSize.Y / 2); }36 //}37 33 38 34 private struct PackingItem { -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/2D/PackingPlan2D.cs
r13477 r13497 33 33 namespace PackingPlanVisualizations { 34 34 public partial class PackingPlan2D : UserControl { 35 WindowRenderTarget wndRender = null;36 Factory2D1 factory = new Factory2D1(FactoryType2D1.SingleThreaded);37 SharpDX.DirectWrite.Factory dwFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared);38 RenderTargetProperties rndTargProperties = new RenderTargetProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied));39 HwndRenderTargetProperties hwndProperties = new HwndRenderTargetProperties();35 private WindowRenderTarget wndRender; 36 private readonly Factory2D1 factory = new Factory2D1(FactoryType2D1.SingleThreaded); 37 private readonly SharpDX.DirectWrite.Factory dwFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared); 38 private readonly RenderTargetProperties rndTargProperties = new RenderTargetProperties(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied)); 39 private HwndRenderTargetProperties hwndProperties; 40 40 41 41 42 #region Packing members BEGIN 43 SolidColorBrush containerBrush; 44 SolidColorBrush containerFillingBrush; 45 SolidColorBrush itemBrush; 46 SolidColorBrush itemFillingBrush; 47 SolidColorBrush labelBrush; 48 TextFormat textFormat; 42 private SolidColorBrush containerBrush; 43 private SolidColorBrush containerFillingBrush; 44 private SolidColorBrush itemBrush; 45 private SolidColorBrush itemFillingBrush; 46 private SolidColorBrush labelBrush; 47 private TextFormat textFormat; 49 48 50 CenteredContainer2D container; 51 #endregion 52 53 //Initialization-Methods 49 private CenteredContainer2D container; 54 50 55 51 public PackingPlan2D() { 56 52 InitializeComponent(); 57 this.SetStyle( 58 ControlStyles.ResizeRedraw, true); 53 this.SetStyle(ControlStyles.ResizeRedraw, true); 59 54 } 60 55 … … 74 69 } 75 70 76 77 78 79 80 //Packing-Methods81 71 public void InitializeContainer(float width, float height) { 82 72 container = new CenteredContainer2D(new Vector2(Math.Max(this.Width - 12, 1), Math.Max(this.Height - 12, 1)), new Vector2(width, height)); … … 86 76 container.AddItem(new Vector2(width, height), new Vector2(x, y), label); 87 77 } 88 89 //Event-Listeners90 78 91 79 private void PackingPlan2D_Load(object sender, EventArgs e) { … … 119 107 wndRender.Resize(new Size2(this.Width, this.Height)); 120 108 } 121 122 109 } 123 110 } -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/BasicCuboidShape.cs
r13465 r13497 27 27 28 28 public class BasicCuboidShape { 29 //Basic information 30 private readonly Vector3 shapeSize; 31 public Vector3 ShapeSize { get { return shapeSize; } } 32 private readonly Vector3 shapePosition; 33 public Vector3 ShapePosition { get { return shapePosition; } } 34 private readonly int shapeID; 35 public int ShapeID { get { return shapeID; } } 36 public int Material { get; set; } 29 public Vector3 ShapeSize { get; private set; } 30 public Vector3 ShapePosition { get; private set; } 31 public int ShapeID { get; private set; } 32 public int Material { get; private set; } 37 33 38 34 39 //Vertices40 35 private VertexPositionColorNormal[] shapeTriangleVertices; 41 36 private VertexPositionColorNormal[] shapeLineVertices; 42 37 43 38 public BasicCuboidShape(Vector3 size, Vector3 position, int shapeNr, int material) { 44 shapeSize = size;45 shapePosition = position;46 shapeID = shapeNr;47 this.Material = material;39 ShapeSize = size; 40 ShapePosition = position; 41 ShapeID = shapeNr; 42 Material = material; 48 43 } 49 44 public BasicCuboidShape(Vector3 size, int shapeNr) : this(size, new Vector3(0, 0, 0), shapeNr, 0) { } … … 53 48 } 54 49 public void RenderShapeLines(GraphicsDevice device, Color color) { 55 shapeLineVertices = (new CuboidShapePreparations(shapeSize, shapePosition, color)).CreateVertexDefinitionsForEdgeLines(); 56 Buffer<VertexPositionColorNormal> shapeLineBuffer = Buffer.Vertex.New( 57 device, 58 shapeLineVertices); 59 VertexInputLayout inputLayoutLine = VertexInputLayout.FromBuffer(0, shapeLineBuffer); 50 shapeLineVertices = 51 new CuboidShapePreparations(ShapeSize, ShapePosition, color).CreateVertexDefinitionsForEdgeLines(); 52 var shapeLineBuffer = Buffer.Vertex.New(device, shapeLineVertices); 53 var inputLayoutLine = VertexInputLayout.FromBuffer(0, shapeLineBuffer); 60 54 61 55 device.SetVertexBuffer(shapeLineBuffer); … … 69 63 70 64 public void RenderShapeTriangles(GraphicsDevice device, Color color) { 71 shapeTriangleVertices = (new CuboidShapePreparations(shapeSize, shapePosition, color)).CreateVertexDefinitionsForTriangles(); 72 Buffer<VertexPositionColorNormal> shapeTriangleBuffer = Buffer.Vertex.New( 73 device, 74 shapeTriangleVertices); 75 VertexInputLayout inputLayoutTriangles = VertexInputLayout.FromBuffer(0, shapeTriangleBuffer); 65 shapeTriangleVertices = 66 new CuboidShapePreparations(ShapeSize, ShapePosition, color).CreateVertexDefinitionsForTriangles(); 67 var shapeTriangleBuffer = Buffer.Vertex.New(device, shapeTriangleVertices); 68 var inputLayoutTriangles = VertexInputLayout.FromBuffer(0, shapeTriangleBuffer); 76 69 77 70 device.SetVertexBuffer(shapeTriangleBuffer); … … 86 79 87 80 public Vector3 CalculatePositionRelativeToBottomLeftBackCorner(Vector3 itemSize, Vector3 itemPosition) { 88 Vector3 newPosition = itemPosition - ( shapeSize / 2 - itemSize / 2);81 Vector3 newPosition = itemPosition - (ShapeSize / 2 - itemSize / 2); 89 82 return newPosition; 90 83 } -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/CenteredContainer.cs
r13465 r13497 27 27 28 28 public class CenteredContainer { 29 private readonly BasicCuboidShape container; 30 private readonly List<BasicCuboidShape> packingItems; 29 public BasicCuboidShape Container { get; private set; } 30 public List<BasicCuboidShape> PackingItems { get; private set; } 31 31 32 private readonly float normalizingFactor; 32 33 33 34 public CenteredContainer(BasicCuboidShape container) { 34 35 normalizingFactor = CalculateNormalizingFactor(container); 35 this.container = Normalize(container);36 packingItems = new List<BasicCuboidShape>();36 Container = Normalize(container); 37 PackingItems = new List<BasicCuboidShape>(); 37 38 } 38 39 … … 45 46 } 46 47 47 48 49 public BasicCuboidShape Container {50 get { return container; }51 }52 public List<BasicCuboidShape> PackingItems {53 get { return packingItems; }54 }55 56 57 48 public void AddPackingItem(Vector3 size, Vector3 position, int index, int material) { 58 Vector3itemSize = size * normalizingFactor;59 Vector3itemPosition = position * normalizingFactor;60 Vector3 actualPosition = container.CalculatePositionRelativeToBottomLeftBackCorner(itemSize, itemPosition);61 BasicCuboidShape itemShape = new BasicCuboidShape(itemSize, actualPosition, index, material);62 packingItems.Add(itemShape);49 var itemSize = size * normalizingFactor; 50 var itemPosition = position * normalizingFactor; 51 var actualPosition = Container.CalculatePositionRelativeToBottomLeftBackCorner(itemSize, itemPosition); 52 var itemShape = new BasicCuboidShape(itemSize, actualPosition, index, material); 53 PackingItems.Add(itemShape); 63 54 } 64 55 } -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/CuboidShapePreparations.cs
r13496 r13497 25 25 public class CuboidShapePreparations { 26 26 27 #region Private Members 27 #region Private Members 28 28 //Define the shape in a way so that the position is in the center of the shape. 29 29 //Define the 8 defining points of the cube 30 Vector3 topLeftFront;31 Vector3 bottomLeftFront;32 Vector3 topRightFront;33 Vector3 bottomRightFront;34 Vector3 topLeftBack;35 Vector3 topRightBack;36 Vector3 bottomLeftBack;37 Vector3 bottomRightBack;30 private readonly Vector3 topLeftFront; 31 private readonly Vector3 bottomLeftFront; 32 private readonly Vector3 topRightFront; 33 private readonly Vector3 bottomRightFront; 34 private readonly Vector3 topLeftBack; 35 private readonly Vector3 topRightBack; 36 private readonly Vector3 bottomLeftBack; 37 private readonly Vector3 bottomRightBack; 38 38 39 39 //Define normal vectors of the 6 surfaces 40 Vector3 frontNormal;41 Vector3 backNormal;42 Vector3 topNormal;43 Vector3 bottomNormal;44 Vector3 leftNormal;45 Vector3 rightNormal;40 private readonly Vector3 frontNormal; 41 private readonly Vector3 backNormal; 42 private readonly Vector3 topNormal; 43 private readonly Vector3 bottomNormal; 44 private readonly Vector3 leftNormal; 45 private readonly Vector3 rightNormal; 46 46 47 47 //Define colors of the 6 surfaces 48 Color frontColor = Color.Black;49 Color backColor = Color.Black;50 Color topColor = Color.Black;51 Color bottomColor = Color.Black;52 Color leftColor = Color.Black;53 Color rightColor = Color.Black;48 private readonly Color frontColor = Color.Black; 49 private readonly Color backColor = Color.Black; 50 private readonly Color topColor = Color.Black; 51 private readonly Color bottomColor = Color.Black; 52 private readonly Color leftColor = Color.Black; 53 private readonly Color rightColor = Color.Black; 54 54 55 55 #endregion Private Members 56 56 57 57 58 public CuboidShapePreparations(Vector3 shapeSize, Vector3 shapePosition) : this 58 public CuboidShapePreparations(Vector3 shapeSize, Vector3 shapePosition) : this(shapeSize, shapePosition, Color.Black) { } 59 59 public CuboidShapePreparations(Vector3 shapeSize, Vector3 shapePosition, Color color) { 60 60 var halfShapeSize = shapeSize / 2; … … 85 85 leftColor = color; 86 86 rightColor = color; 87 88 } 89 90 public VertexPositionColorNormal[] CreateVertexDefinitionsForTriangles () { 87 } 88 89 public VertexPositionColorNormal[] CreateVertexDefinitionsForTriangles() { 91 90 //Definition of the actual triangles 92 91 VertexPositionColorNormal[] shapeVertices = new VertexPositionColorNormal[36]; … … 160 159 public VertexPositionColorNormal[] CreateVertexDefinitionsForEdgeLines(Color color) { 161 160 //Definition of the actual lines 162 VertexPositionColorNormal[]shapeVertices = new VertexPositionColorNormal[48];163 164 Vector3topRightFrontNormal = (topNormal + rightNormal + frontNormal) / 3;165 Vector3topRightBackNormal = (topNormal + rightNormal + backNormal) / 3;166 Vector3topLeftFrontNormal = (topNormal + leftNormal + frontNormal) / 3;167 Vector3topLeftBackNormal = (topNormal + leftNormal + backNormal) / 3;168 Vector3bottomRightFrontNormal = (topNormal + rightNormal + frontNormal) / 3;169 Vector3bottomRightBackNormal = (topNormal + rightNormal + backNormal) / 3;170 Vector3bottomLeftFrontNormal = (topNormal + leftNormal + frontNormal) / 3;171 Vector3bottomLeftBackNormal = (topNormal + leftNormal + backNormal) / 3;161 var shapeVertices = new VertexPositionColorNormal[48]; 162 163 var topRightFrontNormal = (topNormal + rightNormal + frontNormal) / 3; 164 var topRightBackNormal = (topNormal + rightNormal + backNormal) / 3; 165 var topLeftFrontNormal = (topNormal + leftNormal + frontNormal) / 3; 166 var topLeftBackNormal = (topNormal + leftNormal + backNormal) / 3; 167 var bottomRightFrontNormal = (topNormal + rightNormal + frontNormal) / 3; 168 var bottomRightBackNormal = (topNormal + rightNormal + backNormal) / 3; 169 var bottomLeftFrontNormal = (topNormal + leftNormal + frontNormal) / 3; 170 var bottomLeftBackNormal = (topNormal + leftNormal + backNormal) / 3; 172 171 173 172 shapeVertices[0] = new VertexPositionColorNormal(color, topRightFront, topRightFrontNormal); … … 227 226 return shapeVertices; 228 227 } 229 230 231 228 } 232 229 } -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/PackingGame.cs
r13478 r13497 22 22 using System; 23 23 using System.Drawing.Printing; 24 using System.Windows.Forms; 24 25 using SharpDX; 25 26 using SharpDX.Direct3D11; … … 65 66 graphicsDeviceManager.PreparingDeviceSettings += 66 67 (object sender, PreparingDeviceSettingsEventArgs e) => { 67 e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = MSAALevel.X4; 68 e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = MSAALevel.X4; 68 69 return; 69 70 }; 70 var controlColor = Color.White; //System.Drawing.SystemColors.Control;71 var controlColor = Color.White; // System.Drawing.SystemColors.Control; 71 72 backgroundColor = new Color(controlColor.R, controlColor.G, controlColor.B, controlColor.A); 72 73 … … 103 104 protected override void Initialize() { 104 105 base.Initialize(); 105 initializeWorld();106 InitializeWorld(); 106 107 previousMouseState = Mouse.GetState(); 107 108 Console.WriteLine("Initial bounds:" + Window.ClientBounds); 108 109 this.Window.IsMouseVisible = true; 109 110 } 110 private void initializeWorld() {111 private void InitializeWorld() { 111 112 #region Matrix-Initialization 112 113 worldMatrix = Matrix.Identity; … … 233 234 234 235 protected override void Update(GameTime gameTime) { 235 computeMouseHandling();236 ComputeMouseHandling(); 236 237 base.Update(gameTime); 237 238 } … … 242 243 private Vector2 currentViewAngle = new Vector2(0, 0); 243 244 #endregion Mouse-Handling Variables 244 private void computeMouseHandling() {245 private void ComputeMouseHandling() { 245 246 MouseState mouseState = Mouse.GetState(); 246 247 247 computeLeftMouseBtnHandling(mouseState);248 computeMouseWheelHandling(mouseState);248 ComputeLeftMouseBtnHandling(mouseState); 249 ComputeMouseWheelHandling(mouseState); 249 250 250 251 previousMouseState = mouseState; 251 252 } 252 private void computeLeftMouseBtnHandling(MouseState mouseState) {253 private void ComputeLeftMouseBtnHandling(MouseState mouseState) { 253 254 //Left btn pressed 254 255 if (mouseState.LeftButton.Down && (previousMouseState.LeftButton.Pressed || previousMouseState.LeftButton.Down)) { … … 268 269 } 269 270 } 270 private void computeMouseWheelHandling(MouseState mouseState) {271 private void ComputeMouseWheelHandling(MouseState mouseState) { 271 272 int curr = mouseState.WheelDelta; 272 273 if (curr < 0 && zoom > 1) { -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/PackingPlan3D.cs
r13465 r13497 23 23 using System.Windows.Forms; 24 24 using System.Threading; 25 using SharpDX.Toolkit; 26 using SharpDX.Windows; 25 27 26 28 27 29 namespace PackingPlanVisualizations { 28 30 public partial class PackingPlan3D : UserControl { 29 private PackingGame game;31 private readonly PackingGame game; 30 32 private Thread gameLoopThread; 33 private RenderForm renderForm; 31 34 32 35 public PackingPlan3D() { 33 36 InitializeComponent(); 34 if (!(System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")) { 37 38 using (var proc = System.Diagnostics.Process.GetCurrentProcess()) { 39 if (proc.ProcessName == "devenv") return; 35 40 game = new PackingGame(this); 36 41 } … … 39 44 40 45 public void StartRendering() { 41 if (!(System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")) { 46 using (var proc = System.Diagnostics.Process.GetCurrentProcess()) { 47 if (proc.ProcessName == "devenv") return; 42 48 if (!game.IsRunning) 43 49 StartGameLoop(); … … 55 61 new MethodInvoker( 56 62 () => { 57 game.Run(this); 63 var renderForm = new RenderForm("bla"); 64 var gameContext = new GameContext(renderForm); 65 gameContext.UseApplicationDoEvents = false; 66 game.Run(gameContext); 58 67 } 59 68 ) … … 95 104 private void PackingPlan3D_Resize(object sender, EventArgs e) { 96 105 //this.Refresh(); 97 if (!(System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")) { 106 using (var proc = System.Diagnostics.Process.GetCurrentProcess()) { 107 if (proc.ProcessName == "devenv") return; 98 108 game.SetSize(this.Width, this.Height); 99 109 } 100 110 } 111 112 private void PackingPlan3D_MouseEnter(object sender, EventArgs e) { 113 } 114 115 private void PackingPlan3D_MouseLeave(object sender, EventArgs e) { 116 117 } 101 118 } 102 119 } -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/PackingPlanVisualizations.csproj
r13465 r13497 87 87 <Compile Include="3D\BasicCuboidShape.cs" /> 88 88 <Compile Include="3D\CenteredContainer.cs" /> 89 <Compile Include="3D\CuboidShapePrep erations.cs" />89 <Compile Include="3D\CuboidShapePreparations.cs" /> 90 90 <Compile Include="3D\PackingGame.cs" /> 91 91 <Compile Include="3D\PackingPlan3D.cs">
Note: See TracChangeset
for help on using the changeset viewer.