Changeset 14978
- Timestamp:
- 05/12/17 23:37:08 (8 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml
r14971 r14978 55 55 <Transform3DGroup> 56 56 <ScaleTransform3D x:Name="scale" ScaleX="1" ScaleY="1" ScaleZ="1"/> 57 <TranslateTransform3D OffsetX="-0.5" OffsetY="-0.5" OffsetZ="-0.5" /> 58 <RotateTransform3D> 57 <RotateTransform3D x:Name="rotateX"> 59 58 <RotateTransform3D.Rotation> 60 <AxisAngleRotation3D x:Name="rotateX"Axis="0 1 0"/>59 <AxisAngleRotation3D Axis="0 1 0"/> 61 60 </RotateTransform3D.Rotation> 62 61 </RotateTransform3D> 63 <RotateTransform3D >62 <RotateTransform3D x:Name="rotateY"> 64 63 <RotateTransform3D.Rotation> 65 <AxisAngleRotation3D x:Name="rotateY"Axis="1 0 0"/>64 <AxisAngleRotation3D Axis="1 0 0"/> 66 65 </RotateTransform3D.Rotation> 67 66 </RotateTransform3D> 68 <TranslateTransform3D OffsetX="0.5" OffsetY="0.5" OffsetZ="0.5" /> 69 <ScaleTransform3D x:Name="scaleZoom" CenterX="0.5" CenterY="0.5" CenterZ="0.5" ScaleX="1" ScaleY="1" ScaleZ="1"/> 67 <ScaleTransform3D x:Name="scaleZoom" ScaleX="1" ScaleY="1" ScaleZ="1"/> 70 68 </Transform3DGroup> 71 69 </ModelVisual3D.Transform> -
trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml.cs
r14709 r14978 103 103 var hiddenMaterial = new DiffuseMaterial(new SolidColorBrush(hiddenColor)); 104 104 105 foreach (var item in packing.Items) { 106 var position = packing.Positions[item.Key]; 107 108 var w = position.Rotated ? item.Value.Depth : item.Value.Width; 109 var h = item.Value.Height; 110 var d = position.Rotated ? item.Value.Width : item.Value.Depth; 111 112 var model = new GeometryModel3D { Geometry = new MeshGeometry3D() }; 105 if (selectedItemKey >= 0) { 106 var selectedItem = packing.Items.Single(x => selectedItemKey == x.Key); 107 var selectedPos = packing.Positions[selectedItem.Key]; 113 108 DiffuseMaterial material; 114 if (selectedItemKey >= 0 && selectedItemKey != item.Key) 115 material = hiddenMaterial; 116 else { 109 if (!materials.TryGetValue(selectedItem.Value.Material, out material)) { 110 var colorIdx = selectedItem.Value.Material; 111 while (colorIdx < 0) colorIdx += colors.Length; 112 colorIdx = colorIdx % colors.Length; 113 var color = colors[colorIdx]; 114 material = new DiffuseMaterial { Brush = new SolidColorBrush(color) }; 115 materials[selectedItem.Value.Material] = material; 116 } 117 var selectedModel = new GeometryModel3D { Geometry = new MeshGeometry3D(), Material = material }; 118 AddSolidCube((MeshGeometry3D)selectedModel.Geometry, selectedPos.X, selectedPos.Y, selectedPos.Z, 119 selectedPos.Rotated ? selectedItem.Value.Depth : selectedItem.Value.Width, 120 selectedItem.Value.Height, 121 selectedPos.Rotated ? selectedItem.Value.Width : selectedItem.Value.Depth); 122 modelGroup.Children.Add(selectedModel); 123 124 foreach (var item in packing.Items.Where(x => selectedItemKey != x.Key)) { 125 var position = packing.Positions[item.Key]; 126 127 var w = position.Rotated ? item.Value.Depth : item.Value.Width; 128 var h = item.Value.Height; 129 var d = position.Rotated ? item.Value.Width : item.Value.Depth; 130 131 var model = new GeometryModel3D { Geometry = new MeshGeometry3D(), Material = hiddenMaterial }; 132 AddWireframeCube((MeshGeometry3D)model.Geometry, position.X, position.Y, position.Z, w, h, d, 1); 133 modelGroup.Children.Add(model); 134 } 135 } else { 136 foreach (var item in packing.Items) { 137 var position = packing.Positions[item.Key]; 138 139 var w = position.Rotated ? item.Value.Depth : item.Value.Width; 140 var h = item.Value.Height; 141 var d = position.Rotated ? item.Value.Width : item.Value.Depth; 142 143 var model = new GeometryModel3D { Geometry = new MeshGeometry3D() }; 144 DiffuseMaterial material; 117 145 if (!materials.TryGetValue(item.Value.Material, out material)) { 118 146 var colorIdx = item.Value.Material; … … 123 151 materials[item.Value.Material] = material; 124 152 } 153 var selectedModel = new GeometryModel3D { Geometry = new MeshGeometry3D(), Material = material }; 154 AddSolidCube((MeshGeometry3D)selectedModel.Geometry, position.X, position.Y, position.Z, w, h, d); 155 modelGroup.Children.Add(selectedModel); 125 156 } 126 model.Material = material;127 modelGroup.Children.Add(model);128 129 AddSolidCube((MeshGeometry3D)model.Geometry, position.X, position.Y, position.Z, w, h, d);130 157 } 131 158 … … 140 167 scale.ScaleZ = 1.0 / ratio; 141 168 142 scale .CenterX = .5;143 scale .CenterY = .5;144 scale .CenterZ = 0;169 scaleZoom.CenterX = rotateX.CenterX = rotateY.CenterX = container.Width / (2.0 * ratio); 170 scaleZoom.CenterY = rotateX.CenterY = rotateY.CenterY = container.Height / (2.0 * ratio); 171 scaleZoom.CenterZ = rotateX.CenterZ = rotateY.CenterZ = container.Depth / (2.0 * ratio); 145 172 } 146 173 … … 159 186 var pos = e.GetPosition((IInputElement)this); 160 187 161 rotateX.Angle = startAngleX + (pos.X - startPos.X) / 4;162 rotateY.Angle = startAngleY + (pos.Y - startPos.Y) / 4;188 ((AxisAngleRotation3D)rotateX.Rotation).Angle = startAngleX + (pos.X - startPos.X) / 4; 189 ((AxisAngleRotation3D)rotateY.Rotation).Angle = startAngleY + (pos.Y - startPos.Y) / 4; 163 190 } 164 191 165 192 private void Container3DView_MouseDown(object sender, MouseButtonEventArgs e) { 166 startAngleX = rotateX.Angle;167 startAngleY = rotateY.Angle;193 startAngleX = ((AxisAngleRotation3D)rotateX.Rotation).Angle; 194 startAngleY = ((AxisAngleRotation3D)rotateY.Rotation).Angle; 168 195 this.startPos = e.GetPosition((IInputElement)this); 169 196 this.mouseDown = true; … … 302 329 mesh.Positions.Add(new Point3D(x + thickness, y + height, z + depth)); 303 330 304 AddPlane(mesh, 0, 4, 6, 2); 305 AddPlane(mesh, 0, 3, 5, 4); 306 307 AddPlane(mesh, 4, 8, 10, 6); 308 AddPlane(mesh, 4, 7, 9, 8); 309 310 AddPlane(mesh, 8, 12, 14, 10); 311 AddPlane(mesh, 8, 11, 13, 12); 312 313 AddPlane(mesh, 0, 2, 14, 12); 314 AddPlane(mesh, 0, 12, 15, 1); 315 316 AddPlane(mesh, 0, 1, 17, 16); 317 AddPlane(mesh, 0, 16, 19, 3); 318 319 AddPlane(mesh, 4, 20, 23, 7); 320 AddPlane(mesh, 4, 5, 21, 20); 321 322 AddPlane(mesh, 8, 24, 27, 11); 323 AddPlane(mesh, 8, 9, 25, 24); 324 325 AddPlane(mesh, 12, 28, 31, 15); 326 AddPlane(mesh, 12, 13, 29, 28); 327 328 AddPlane(mesh, 16, 18, 22, 20); 329 AddPlane(mesh, 16, 20, 21, 19); 330 331 AddPlane(mesh, 20, 22, 26, 24); 332 AddPlane(mesh, 20, 24, 25, 23); 333 334 AddPlane(mesh, 24, 28, 29, 27); 335 AddPlane(mesh, 24, 26, 30, 28); 336 337 AddPlane(mesh, 28, 30, 18, 16); 338 AddPlane(mesh, 28, 16, 17, 31); 331 // Point 0, non-edge 332 mesh.Positions.Add(new Point3D(x + thickness, y, z + thickness)); 333 mesh.Positions.Add(new Point3D(x, y + thickness, z + thickness)); 334 mesh.Positions.Add(new Point3D(x + thickness, y + thickness, z)); 335 336 // Point 1, non-edge 337 mesh.Positions.Add(new Point3D(x + width, y + thickness, z + thickness)); 338 mesh.Positions.Add(new Point3D(x + width - thickness, y, z + thickness)); 339 mesh.Positions.Add(new Point3D(x + width - thickness, y + thickness, z)); 340 341 // Point 2, non-edge 342 mesh.Positions.Add(new Point3D(x + width - thickness, y + height, z + thickness)); 343 mesh.Positions.Add(new Point3D(x + width, y + height - thickness, z + thickness)); 344 mesh.Positions.Add(new Point3D(x + width - thickness, y + height - thickness, z)); 345 346 // Point 3, non-edge 347 mesh.Positions.Add(new Point3D(x, y + height - thickness, z + thickness)); 348 mesh.Positions.Add(new Point3D(x + thickness, y + height, z + thickness)); 349 mesh.Positions.Add(new Point3D(x + thickness, y + height - thickness, z)); 350 351 // Point 4, non-edge 352 mesh.Positions.Add(new Point3D(x + thickness, y, z + depth - thickness)); 353 mesh.Positions.Add(new Point3D(x, y + thickness, z + depth - thickness)); 354 mesh.Positions.Add(new Point3D(x + thickness, y + thickness, z + depth)); 355 356 // Point 5, non-edge 357 mesh.Positions.Add(new Point3D(x + width, y + thickness, z + depth - thickness)); 358 mesh.Positions.Add(new Point3D(x + width - thickness, y, z + depth - thickness)); 359 mesh.Positions.Add(new Point3D(x + width - thickness, y + thickness, z + depth)); 360 361 // Point 6, non-edge 362 mesh.Positions.Add(new Point3D(x + width - thickness, y + height, z + depth - thickness)); 363 mesh.Positions.Add(new Point3D(x + width, y + height - thickness, z + depth - thickness)); 364 mesh.Positions.Add(new Point3D(x + width - thickness, y + height - thickness, z + depth)); 365 366 // Point 7, non-edge 367 mesh.Positions.Add(new Point3D(x, y + height - thickness, z + depth - thickness)); 368 mesh.Positions.Add(new Point3D(x + thickness, y + height, z + depth - thickness)); 369 mesh.Positions.Add(new Point3D(x + thickness, y + height - thickness, z + depth)); 370 371 // Draw the 24 corner plates 372 AddPlane(mesh, 0, 1, 32, 2); 373 AddPlane(mesh, 0, 2, 33, 3); 374 AddPlane(mesh, 0, 3, 34, 1); 375 376 AddPlane(mesh, 4, 6, 36, 7); 377 AddPlane(mesh, 4, 5, 35, 6); 378 AddPlane(mesh, 4, 7, 37, 5); 379 380 AddPlane(mesh, 8, 10, 39, 11); 381 AddPlane(mesh, 8, 9, 38, 10); 382 AddPlane(mesh, 8, 11, 40, 9); 383 384 AddPlane(mesh, 12, 13, 41, 14); 385 AddPlane(mesh, 12, 14, 42, 15); 386 AddPlane(mesh, 12, 15, 43, 13); 387 388 AddPlane(mesh, 16, 18, 44, 17); 389 AddPlane(mesh, 16, 19, 45, 18); 390 AddPlane(mesh, 16, 17, 46, 19); 391 392 AddPlane(mesh, 20, 23, 48, 22); 393 AddPlane(mesh, 20, 22, 47, 21); 394 AddPlane(mesh, 20, 21, 49, 23); 395 396 AddPlane(mesh, 24, 27, 51, 26); 397 AddPlane(mesh, 24, 26, 50, 25); 398 AddPlane(mesh, 24, 25, 52, 27); 399 400 AddPlane(mesh, 28, 31, 54, 30); 401 AddPlane(mesh, 28, 30, 53, 29); 402 AddPlane(mesh, 28, 29, 55, 31); 403 404 // Draw the connecting plates 405 // on the bottom 406 AddPlane(mesh, 1, 7, 36, 32); 407 AddPlane(mesh, 1, 34, 37, 7); 408 409 AddPlane(mesh, 5, 11, 39, 35); 410 AddPlane(mesh, 5, 37, 40, 11); 411 412 AddPlane(mesh, 9, 15, 42, 38); 413 AddPlane(mesh, 9, 40, 43, 15); 414 415 AddPlane(mesh, 13, 3, 33, 41); 416 AddPlane(mesh, 13, 43, 34, 3); 417 418 // between bottom and top 419 AddPlane(mesh, 2, 32, 44, 18); 420 AddPlane(mesh, 2, 18, 45, 33); 421 422 AddPlane(mesh, 6, 22, 48, 36); 423 AddPlane(mesh, 6, 35, 47, 22); 424 425 AddPlane(mesh, 10, 26, 51, 39); 426 AddPlane(mesh, 10, 38, 50, 26); 427 428 AddPlane(mesh, 14, 30, 54, 42); 429 AddPlane(mesh, 14, 41, 53, 30); 430 431 // on the top 432 AddPlane(mesh, 17, 44, 48, 23); 433 AddPlane(mesh, 17, 23, 49, 46); 434 435 AddPlane(mesh, 21, 47, 51, 27); 436 AddPlane(mesh, 21, 27, 52, 49); 437 438 AddPlane(mesh, 25, 50, 54, 31); 439 AddPlane(mesh, 25, 31, 55, 52); 440 441 AddPlane(mesh, 29, 19, 46, 55); 442 AddPlane(mesh, 29, 53, 45, 19); 339 443 } 340 444
Note: See TracChangeset
for help on using the changeset viewer.