Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/14/15 20:23:19 (9 years ago)
Author:
gkronber
Message:

#1966: general code cleanup ...

Location:
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/BasicCuboidShape.cs

    r13032 r13465  
    2525
    2626namespace PackingPlanVisualizations {
    27  
     27
    2828  public class BasicCuboidShape {
    2929    //Basic information
    30     private Vector3 shapeSize;
     30    private readonly Vector3 shapeSize;
    3131    public Vector3 ShapeSize { get { return shapeSize; } }
    32     private Vector3 shapePosition;
     32    private readonly Vector3 shapePosition;
    3333    public Vector3 ShapePosition { get { return shapePosition; } }
    34     private int shapeID;
     34    private readonly int shapeID;
    3535    public int ShapeID { get { return shapeID; } }
    3636    public int Material { get; set; }
    3737
    3838
    39     //Vertices                                       
     39    //Vertices
    4040    private VertexPositionColorNormal[] shapeTriangleVertices;
    4141    private VertexPositionColorNormal[] shapeLineVertices;
    4242
    4343    public BasicCuboidShape(Vector3 size, Vector3 position, int shapeNr, int material) {
    44       shapeSize       = size;
    45       shapePosition   = position;
    46       shapeID     = shapeNr;
     44      shapeSize = size;
     45      shapePosition = position;
     46      shapeID = shapeNr;
    4747      this.Material = material;
    4848    }
     
    6565
    6666    public void RenderShapeTriangles(GraphicsDevice device) {
    67       RenderShapeTriangles(device, Material == 0 ? new Color(60,60,60) :new Color (0,0,0));
     67      RenderShapeTriangles(device, Material == 0 ? new Color(60, 60, 60) : new Color(0, 0, 0));
    6868    }
    6969
     
    8585    }
    8686
    87     public Vector3 CalculatePositionRelativeToBottomLeftBackCorner(Vector3 itemSize, Vector3 itemPosition) {     
    88       //Vector3 bottomLeftBack = shapePosition + new Vector3(-1.0f, -1.0f, 1.0f) * shapeSize;
    89       Vector3 newPosition = itemPosition - (shapeSize/2 - itemSize/2);
     87    public Vector3 CalculatePositionRelativeToBottomLeftBackCorner(Vector3 itemSize, Vector3 itemPosition) {
     88      Vector3 newPosition = itemPosition - (shapeSize / 2 - itemSize / 2);
    9089      return newPosition;
    9190    }
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/CenteredContainer.cs

    r13032 r13465  
    2727
    2828  public class CenteredContainer {
    29     private BasicCuboidShape container;
    30     private List<BasicCuboidShape> packingItems;
    31     private float normalizingFactor;
     29    private readonly BasicCuboidShape container;
     30    private readonly List<BasicCuboidShape> packingItems;
     31    private readonly float normalizingFactor;
    3232
    3333    public CenteredContainer(BasicCuboidShape container) {
     
    5858      Vector3 itemSize = size * normalizingFactor;
    5959      Vector3 itemPosition = position * normalizingFactor;
    60       //Apply rotation = swap X and Y size
    61       //if (rotated) {
    62       //  float aux = itemSize.X;
    63       //  itemSize.X = itemSize.Y;
    64       //  itemSize.Y = aux;
    65       //}
    6660      Vector3 actualPosition = container.CalculatePositionRelativeToBottomLeftBackCorner(itemSize, itemPosition);
    6761      BasicCuboidShape itemShape = new BasicCuboidShape(itemSize, actualPosition, index, material);
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/CuboidShapePreperations.cs

    r13032 r13465  
    5353    Color rightColor = Color.Black;
    5454
    55     //Define positions of the textures
    56     Vector2 textureTopLeft;
    57     Vector2 textureTopRight;
    58     Vector2 textureBottomLeft;
    59     Vector2 textureBottomRight;
    6055    #endregion Private Members
    6156
     
    9186      rightColor = color;
    9287
    93       //Define positions of the textures
    94       textureTopLeft = new Vector2(0.5f * halfShapeSize.X, 0.0f * halfShapeSize.Y);
    95       textureTopRight = new Vector2(0.0f * halfShapeSize.X, 0.0f * halfShapeSize.Y);
    96       textureBottomLeft = new Vector2(0.5f * halfShapeSize.X, 0.5f * halfShapeSize.Y);
    97       textureBottomRight = new Vector2(0.0f * halfShapeSize.X, 0.5f * halfShapeSize.Y);
    9888    }
    9989
     
    171161      //Definition of the actual lines
    172162      VertexPositionColorNormal[] shapeVertices = new VertexPositionColorNormal[48];
    173 
    174       //shapeVertices[0] = new VertexPositionColorNormal(color, topRightFront, frontNormal);
    175       //shapeVertices[1] = new VertexPositionColorNormal(color, topLeftFront, frontNormal);
    176       //shapeVertices[2] = new VertexPositionColorNormal(color, topLeftFront, frontNormal);
    177       //shapeVertices[3] = new VertexPositionColorNormal(color, bottomLeftFront, frontNormal);
    178       //shapeVertices[4] = new VertexPositionColorNormal(color, bottomLeftFront, frontNormal);
    179       //shapeVertices[5] = new VertexPositionColorNormal(color, bottomRightFront, frontNormal);
    180       //shapeVertices[6] = new VertexPositionColorNormal(color, bottomRightFront, frontNormal);
    181       //shapeVertices[7] = new VertexPositionColorNormal(color, topRightFront, frontNormal);
    182 
    183       //shapeVertices[8] = new VertexPositionColorNormal(color, topRightBack, backNormal);
    184       //shapeVertices[9] = new VertexPositionColorNormal(color, topLeftBack, backNormal);
    185       //shapeVertices[10] = new VertexPositionColorNormal(color, topLeftBack, backNormal);
    186       //shapeVertices[11] = new VertexPositionColorNormal(color, bottomLeftBack, backNormal);
    187       //shapeVertices[12] = new VertexPositionColorNormal(color, bottomLeftBack, backNormal);
    188       //shapeVertices[13] = new VertexPositionColorNormal(color, bottomRightBack, backNormal);
    189       //shapeVertices[14] = new VertexPositionColorNormal(color, bottomRightBack, backNormal);
    190       //shapeVertices[15] = new VertexPositionColorNormal(color, topRightBack, backNormal);
    191 
    192       //shapeVertices[16] = new VertexPositionColorNormal(color, topLeftFront, topNormal);
    193       //shapeVertices[17] = new VertexPositionColorNormal(color, topLeftBack, topNormal);
    194       //shapeVertices[18] = new VertexPositionColorNormal(color, topRightFront, topNormal);
    195       //shapeVertices[19] = new VertexPositionColorNormal(color, topRightBack, topNormal);
    196       //shapeVertices[20] = new VertexPositionColorNormal(color, topLeftFront, topNormal);
    197       //shapeVertices[21] = new VertexPositionColorNormal(color, topRightFront, topNormal);
    198       //shapeVertices[22] = new VertexPositionColorNormal(color, topRightBack, topNormal);
    199       //shapeVertices[23] = new VertexPositionColorNormal(color, topLeftBack, topNormal);
    200 
    201       //shapeVertices[24] = new VertexPositionColorNormal(color, bottomLeftFront, bottomNormal);
    202       //shapeVertices[25] = new VertexPositionColorNormal(color, bottomRightFront, bottomNormal);
    203       //shapeVertices[26] = new VertexPositionColorNormal(color, bottomLeftBack, bottomNormal);
    204       //shapeVertices[27] = new VertexPositionColorNormal(color, bottomRightBack, bottomNormal);
    205       //shapeVertices[28] = new VertexPositionColorNormal(color, bottomRightFront, bottomNormal);
    206       //shapeVertices[29] = new VertexPositionColorNormal(color, bottomRightBack, bottomNormal);
    207       //shapeVertices[30] = new VertexPositionColorNormal(color, bottomLeftFront, bottomNormal);
    208       //shapeVertices[31] = new VertexPositionColorNormal(color, bottomLeftBack, bottomNormal);
    209 
    210       //shapeVertices[32] = new VertexPositionColorNormal(color, topLeftFront, leftNormal);
    211       //shapeVertices[33] = new VertexPositionColorNormal(color, topLeftBack, leftNormal);
    212       //shapeVertices[34] = new VertexPositionColorNormal(color, topLeftBack, leftNormal);
    213       //shapeVertices[35] = new VertexPositionColorNormal(color, bottomLeftBack, leftNormal);
    214       //shapeVertices[36] = new VertexPositionColorNormal(color, bottomLeftBack, leftNormal);
    215       //shapeVertices[37] = new VertexPositionColorNormal(color, bottomLeftFront, leftNormal);
    216       //shapeVertices[38] = new VertexPositionColorNormal(color, bottomLeftFront, leftNormal);
    217       //shapeVertices[39] = new VertexPositionColorNormal(color, topLeftFront, leftNormal);
    218 
    219       //shapeVertices[40] = new VertexPositionColorNormal(color, topRightFront, rightNormal);
    220       //shapeVertices[41] = new VertexPositionColorNormal(color, topRightBack, rightNormal);
    221       //shapeVertices[42] = new VertexPositionColorNormal(color, topRightBack, rightNormal);
    222       //shapeVertices[43] = new VertexPositionColorNormal(color, bottomRightBack, rightNormal);
    223       //shapeVertices[44] = new VertexPositionColorNormal(color, bottomRightBack, rightNormal);
    224       //shapeVertices[45] = new VertexPositionColorNormal(color, bottomRightFront, rightNormal);
    225       //shapeVertices[46] = new VertexPositionColorNormal(color, bottomRightFront, rightNormal);
    226       //shapeVertices[47] = new VertexPositionColorNormal(color, topRightFront, rightNormal);
    227163
    228164      Vector3 topRightFrontNormal = (topNormal + rightNormal + frontNormal) / 3;
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/PackingGame.cs

    r13161 r13465  
    106106      Console.WriteLine("Initial bounds:" + Window.ClientBounds);
    107107      this.Window.IsMouseVisible = true;
    108       //this.Window.ClientSizeChanged += (a, b) => {
    109       //  Console.WriteLine("Resized..");
    110       //  this.Tick();
    111       //};
    112108    }
    113109    private void initializeWorld() {
     
    177173
    178174      #region Transparency
    179 
    180       //basicEffect.GraphicsDevice.RenderState.AlphaBlendEnable = true;
    181       //basicEffect.GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;
    182       //basicEffect.GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;   
    183175
    184176      BlendStateDescription blendStateDescription = new SharpDX.Direct3D11.BlendStateDescription();
     
    264256    private void computeLeftMouseBtnHandling(MouseState mouseState) {
    265257      //Left btn released
    266       if (mouseState.LeftButton.Released && mouseState.LeftButton.Equals(previousMouseState.LeftButton)) {
    267         //Console.WriteLine("Released");
    268       }
     258      //if (mouseState.LeftButton.Released && mouseState.LeftButton.Equals(previousMouseState.LeftButton)) {
     259      //  //Console.WriteLine("Released");
     260      //} else
    269261
    270262      //Left btn pressed
    271       else if (mouseState.LeftButton.Pressed && mouseState.LeftButton.Equals(previousMouseState.LeftButton)) {
     263
     264      if (mouseState.LeftButton.Pressed && mouseState.LeftButton.Equals(previousMouseState.LeftButton)) {
    272265        currentViewAngle = new Vector2(
    273266          viewAngleOnBtnRelease.X + mouseState.X - mousePositionOnBtnDown.X,
    274267          viewAngleOnBtnRelease.Y + mouseState.Y - mousePositionOnBtnDown.Y);
    275268
    276         //angle += 0.5f;
    277         //Console.WriteLine("Pressed");
    278         //Console.WriteLine(currentViewAngle.ToString());
    279269      }
    280270
    281271      //Left btn freshly pressed ==> ONLICK-EVENT
    282272      else if (mouseState.LeftButton.Pressed && !previousMouseState.LeftButton.Pressed) {
    283         Console.WriteLine("OnClick");
    284         PackingPlan3D native = (PackingPlan3D)Window.NativeWindow;
    285         Console.WriteLine("Window: " + Window.ClientBounds.ToString());
    286         Console.WriteLine("native: " + native.ClientSize.ToString());
    287         Console.WriteLine("native.parent: " + native.Parent.ClientSize.ToString());
    288 
    289         Console.WriteLine(native.ParentForm.ToString());
    290         Console.WriteLine(Window.Name);
    291         Console.WriteLine(this.IsActive);
     273        //Console.WriteLine("OnClick");
     274        //PackingPlan3D native = (PackingPlan3D)Window.NativeWindow;
     275        //Console.WriteLine("Window: " + Window.ClientBounds.ToString());
     276        //Console.WriteLine("native: " + native.ClientSize.ToString());
     277        //Console.WriteLine("native.parent: " + native.Parent.ClientSize.ToString());
     278        //
     279        //Console.WriteLine(native.ParentForm.ToString());
     280        //Console.WriteLine(Window.Name);
     281        //Console.WriteLine(this.IsActive);
    292282        mousePositionOnBtnDown = new Vector2(mouseState.X, mouseState.Y);
    293283      }
     
    295285      //Left btn freshly released ==> ONRELEASE-EVENT
    296286      else if (mouseState.LeftButton.Released && !previousMouseState.LeftButton.Released) {
    297         Console.WriteLine("OnRelease");
     287        //Console.WriteLine("OnRelease");
    298288        viewAngleOnBtnRelease = currentViewAngle;
    299289      }
     
    304294      if (curr < prev && zoom > 1) {
    305295        zoom++;
    306         Console.WriteLine(zoom);
     296        //Console.WriteLine(zoom);
    307297      } else if (curr > prev && zoom < 300) {
    308298        zoom--;
    309         Console.WriteLine(zoom);
     299        //Console.WriteLine(zoom);
    310300      }
    311301    }
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/PackingPlan3D.cs

    r13032 r13465  
    2525
    2626
    27 namespace PackingPlanVisualizations { 
     27namespace PackingPlanVisualizations {
    2828  public partial class PackingPlan3D : UserControl {
    2929    private PackingGame game;
     
    6767
    6868
    69 
    70     #region Archive ..
    71     //private BasicCuboidShape containerShape;
    72     //private List<BasicCuboidShape> itemShapes;
    73     //private void RunGame() {
    74     //  if (containerShape == null)
    75     //    return;
    76     //  game = new PackingGame(this);
    77     //  game.InitializeContainer(containerShape);
    78     //  foreach (BasicCuboidShape shape in itemShapes)
    79     //    game.AddItemToContainer(shape);
    80     //  game.Run(this);
    81     //}
    82     #endregion
    83 
    84 
    85 
    8669    public void InitializeContainer(float width, float height, float depth) {
    8770      //if (game != null) {
     
    9578
    9679    public void AddItemToContainer(float width, float height, float depth, float x, float y, float z, int itemNr) {
    97       AddItemToContainer(width, height, depth, x,y,z, itemNr, 0);
     80      AddItemToContainer(width, height, depth, x, y, z, itemNr, 0);
    9881    }
    9982    public void AddItemToContainer(float width, float height, float depth, float x, float y, float z, int itemNr, int material) {
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/VertexPositionColorNormal.cs

    r13032 r13465  
    2424using SharpDX.Toolkit.Graphics;
    2525
    26 namespace PackingPlanVisualizations {               
     26namespace PackingPlanVisualizations {
    2727
    2828  [Serializable]
     
    5050
    5151    public override bool Equals(object obj) {
    52       if (obj.GetType() == typeof (VertexPositionColorNormal))
     52      if (obj is VertexPositionColorNormal)
    5353        return this.Equals((VertexPositionColorNormal)obj);
    5454      else
Note: See TracChangeset for help on using the changeset viewer.