public void TestBoxInFront() { Vector3D vCameraPos = new Vector3D(-10000.0, -10000.0, 10000.0); Vector3D vTarget = new Vector3D(0.0, 0.0, 0.0); Vector3D vDir = vTarget - vCameraPos; Box b1 = new Box(1, 100.0, 100.0, 100.0); b1.Position = new Vector3D(900.0, 900.0, 0.0); Box b2 = new Box(2, 100.0, 100.0, 100.0); b2.Position = new Vector3D(800.0, 900.0, 0.0); Box b3 = new Box(3, 100.0, 100.0, 100.0); b3.Position = new Vector3D(900.0, 800.0, 0.0); Box b4 = new Box(3, 100.0, 100.0, 100.0); b4.Position = new Vector3D(800.0, 800.0, 0.0); Box b5 = new Box(3, 1000.0, 100.0, 100.0); b5.Position = new Vector3D(0.0, 900.0, 0.0); Box b6 = new Box(3, 100.0, 1000.0, 100.0); b6.Position = new Vector3D(900.0, 0.0, 0.0); Assert.False(b2.BoxInFront(b1, vDir)); Assert.False(b3.BoxInFront(b1, vDir)); Assert.False(b4.BoxInFront(b1, vDir)); Assert.False(b4.BoxInFront(b2, vDir)); Assert.False(b4.BoxInFront(b3, vDir)); Assert.False(b3.BoxInFront(b5, vDir)); Assert.False(b2.BoxInFront(b6, vDir)); }
public void TestIsPointInFront() { Face f = new Face(0, Vector3D.Zero, new Vector3D(100.0, 0.0, 0.0), new Vector3D(100.0, 0.0, 100.0), new Vector3D(0.0, 0.0, 100.0)); Vector3D viewDir = new Vector3D(1.0, 1.0, -1.0); Assert.False(f.PointIsInFront(new Vector3D(50.0, 100.0, 50.0), viewDir)); Assert.True(f.PointIsInFront(new Vector3D(50.0, -100.0, 50.0), viewDir)); }
public void TestIsPointBehind() { Box b1 = new Box(1, 100.0, 100.0, 100.0); Vector3D viewDir = new Vector3D(1.0, 1.0, -1.0); Assert.True(b1.PointBehind(new Vector3D(50.0, 150.0, 50.0), viewDir)); Assert.False(b1.PointBehind(new Vector3D(50.0, -150.0, 50.0), viewDir)); }
static void Main(string[] args) { bool bestLayersOnly = true; Vector3D dimBox = new Vector3D(400.0, 300.0, 150.0); Vector2D dimContainer = new Vector2D(1200.0, 1000.0); ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet(); constraintSet.SetMaxHeight(1200.0); try { LayerSolver solver = new LayerSolver(); List<Layer2D> layers = solver.BuildLayers(dimBox, dimContainer, constraintSet, bestLayersOnly); int solIndex = 0; foreach (Layer2D layer in layers) { string fileName = string.Format("{0}_{1}.bmp", layer.Name, solIndex++); string filePath = Path.Combine(Path.GetTempPath(), fileName); Console.WriteLine(string.Format("Generating {0}...", filePath)); Graphics2DImage graphics = new Graphics2DImage( new Size(150, 150) ); SolutionViewerLayer solViewer = new SolutionViewerLayer(layer); BoxProperties bProperties = new BoxProperties(null, 400.0, 300.0, 150.0); bProperties.SetColor(Color.Brown); solViewer.Draw(graphics, bProperties, 1500.0); graphics.SaveAs(filePath); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void AddPosition(LayerCyl layer, Vector2D vPosition) { Matrix4D matRot = Matrix4D.Identity; Vector3D vTranslation = Vector3D.Zero; if (_swapped) { matRot = new Matrix4D( 0.0, -1.0, 0.0, 0.0 , 1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0 ); vTranslation = new Vector3D(layer.PalletLength, 0.0, 0.0); } Transform3D transfRot = new Transform3D(matRot); matRot.M14 = vTranslation[0]; matRot.M24 = vTranslation[1]; matRot.M34 = vTranslation[2]; Transform3D transfRotTranslation = new Transform3D(matRot); Vector3D vPositionSwapped = transfRotTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0)); if (!layer.IsValidPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y))) { _log.Warn(string.Format("Attempt to add an invalid position in pattern = {0}, Swapped = true", this.Name)); return; } layer.Add(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y)); }
public void TestCompareOrtho() { Vector3D vCameraPos = new Vector3D(-10000.0, -10000.0, 10000.0); Vector3D vTarget = new Vector3D(0.0, 0.0, 0.0); BoxComparer comparer = new BoxComparer(vCameraPos, vTarget); Box b1 = new Box(1, 100.0, 100.0, 100.0); b1.Position = new Vector3D(900.0, 900.0, 0.0); Box b2 = new Box(2, 100.0, 100.0, 100.0); b2.Position = new Vector3D(800.0, 900.0, 0.0); Box b3 = new Box(3, 100.0, 100.0, 100.0); b3.Position = new Vector3D(900.0, 800.0, 0.0); Box b4 = new Box(4, 100.0, 100.0, 100.0); b4.Position = new Vector3D(800.0, 800.0, 0.0); Assert.AreEqual(0, comparer.Compare(b1, b1)); Assert.AreEqual(-1, comparer.Compare(b1, b2)); Assert.AreEqual(1, comparer.Compare(b2, b1)); Assert.AreEqual(-1, comparer.Compare(b1, b3)); Assert.AreEqual(1, comparer.Compare(b3, b1)); Assert.AreEqual(-1, comparer.Compare(b1, b4)); Assert.AreEqual(1, comparer.Compare(b4, b1)); Assert.AreEqual(-1, comparer.Compare(b2, b4)); Assert.AreEqual(1, comparer.Compare(b4, b2)); Assert.AreEqual(-1, comparer.Compare(b3, b4)); Assert.AreEqual(1, comparer.Compare(b4, b3)); }
public List<Layer2D> BuildLayers(Vector3D dimBox, Vector2D dimContainer, ConstraintSetAbstract constraintSet, bool keepOnlyBest) { // instantiate list of layers List<Layer2D> listLayers0 = new List<Layer2D>(); // loop through all patterns foreach (LayerPattern pattern in LayerPattern.All) { // loop through all orientation foreach (HalfAxis.HAxis axisOrtho in HalfAxis.All) { // is orientation allowed if ( !constraintSet.AllowOrientation(axisOrtho) ) continue; // not swapped vs swapped pattern for (int iSwapped = 0; iSwapped < 1; ++iSwapped) { // does swapping makes sense for this layer pattern ? if (!pattern.CanBeSwapped && (iSwapped == 1)) continue; // instantiate layer Layer2D layer = new Layer2D(dimBox, dimContainer, axisOrtho, iSwapped == 1); layer.PatternName = pattern.Name; double actualLength = 0.0, actualWidth = 0.0; if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth)) continue; pattern.GenerateLayer(layer, actualLength, actualWidth); if (0 == layer.Count) continue; listLayers0.Add(layer); } } } // keep only best layers if (keepOnlyBest) { // 1. get best count int bestCount = 0; foreach (Layer2D layer in listLayers0) bestCount = Math.Max(layer.CountInHeight(constraintSet.OptMaxHeight.Value), bestCount); // 2. remove any layer that does not match the best count given its orientation List<Layer2D> listLayers1 = new List<Layer2D>(); foreach (Layer2D layer in listLayers0) { if (layer.CountInHeight(constraintSet.OptMaxHeight.Value) >= bestCount) listLayers1.Add(layer); } // 3. copy back in original list listLayers0.Clear(); listLayers0.AddRange(listLayers1); } if (constraintSet.OptMaxHeight.Activated) listLayers0.Sort(new LayerComparerCount(constraintSet.OptMaxHeight.Value)); return listLayers0; }
public DimensionCube(Basics.BBox3D bbox, Color color, bool above) { _position = bbox.PtMin; _dim[0] = bbox.Length; _dim[1] = bbox.Width; _dim[2] = bbox.Height; _color = color; _above = above; for (int i = 0; i < 3; ++i) _showArrow[i] = true; BuildPoints(); }
public DimensionCube(Vector3D position, double length, double width, double height, Color color, bool above) { _position = position; _dim[0] = length; _dim[1] = width; _dim[2] = height; _color = color; _above = above; for (int i = 0; i < 3; ++i) _showArrow[i] = true; BuildPoints(); }
public PalletCap(uint pickId, PalletCapProperties capProperties, Vector3D position) { _dim[0] = capProperties.Length; _dim[1] = capProperties.Width; _dim[2] = capProperties.Height; _color = capProperties.Color; Position = position; }
//����������ϵ�еĶ������ù����任���ֲ�����ϵ�� public Vector2D TransformPosition(Vector2D refPos) { //�����������ϵ�е����� Vector2D relPos = GetRelPositon(refPos); Vector3D homoPos = new Vector3D(relPos.X, relPos.Y, 1.0); //�ӹ�������ϵ�任���ֲ�����ϵ Vector3D TransformedPos = Matrix3D.Transform(m_totalMat, homoPos); return new Vector2D(TransformedPos.X, TransformedPos.Y); }
private PalletData(string name, string description, Vector3D[] lumbers, Position[] positions, Vector3D dimensions, double weight, Color color) { _name = name; _description = description; _lumbers = new List<Vector3D>(lumbers); _positions = new List<Position>(positions); _defaultDimensions = dimensions; _weight = weight; _color = color; }
public void Extend(Vector3D vec) { _ptMin.X = Math.Min(_ptMin.X, vec.X); _ptMin.Y = Math.Min(_ptMin.Y, vec.Y); _ptMin.Z = Math.Min(_ptMin.Z, vec.Z); _ptMax.X = Math.Max(_ptMax.X, vec.X); _ptMax.Y = Math.Max(_ptMax.Y, vec.Y); _ptMax.Z = Math.Max(_ptMax.Z, vec.Z); }
public FilmRectangle( Vector3D origin, HalfAxis.HAxis axis1, HalfAxis.HAxis axis2, Vector2D dimensions, double dBorder) { _origin = origin; _axis1 = axis1; _axis2 = axis2; _dimensions = dimensions; _dBorder = dBorder; }
public void AddPosition(Layer layer, Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { Matrix4D matRot = Matrix4D.Identity; Vector3D vTranslation = Vector3D.Zero; if (_swapped && !layer.Inversed) { matRot = new Matrix4D( 0.0, -1.0, 0.0, 0.0 , 1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0 ); vTranslation = new Vector3D(layer.PalletLength, 0.0, 0.0); } else if (!_swapped && layer.Inversed) { matRot = new Matrix4D( -1.0, 0.0, 0.0, 0.0 , 0.0, -1.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0 ); vTranslation = new Vector3D(layer.PalletLength, layer.PalletWidth, 0.0); } else if (_swapped && layer.Inversed) { matRot = new Matrix4D( 0.0, 1.0, 0.0, 0.0 , -1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0 ); vTranslation = new Vector3D(0.0, layer.PalletWidth, 0.0); } Transform3D transfRot = new Transform3D(matRot); HalfAxis.HAxis lengthAxisSwapped = StackBuilder.Basics.HalfAxis.ToHalfAxis(transfRot.transform(StackBuilder.Basics.HalfAxis.ToVector3D(lengthAxis))); HalfAxis.HAxis widthAxisSwapped = StackBuilder.Basics.HalfAxis.ToHalfAxis(transfRot.transform(StackBuilder.Basics.HalfAxis.ToVector3D(widthAxis))); matRot.M14 = vTranslation[0]; matRot.M24 = vTranslation[1]; matRot.M34 = vTranslation[2]; Transform3D transfRotTranslation = new Transform3D(matRot); Vector3D vPositionSwapped = transfRotTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0)); if (!layer.IsValidPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y), lengthAxisSwapped, widthAxisSwapped)) { _log.Warn(string.Format("Attempt to add an invalid position in pattern = {0}, Variant = {1}, Swapped = true", this.Name, _variantIndex)); return; } layer.AddPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y), lengthAxisSwapped, widthAxisSwapped); }
public Layer2D BuildLayer(Vector3D dimBox, Vector2D dimContainer, LayerDesc layerDesc) { // instantiate layer Layer2D layer = new Layer2D(dimBox, dimContainer, layerDesc.AxisOrtho, false); // get layer pattern LayerPattern pattern = LayerPattern.GetByName(layerDesc.PatternName); // dimensions double actualLength = 0.0, actualWidth = 0.0; if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth)) return null; pattern.GenerateLayer(layer, actualLength, actualWidth); return layer; }
public CaseOptimConstraintSet( int[] noWalls , double wallThickness, double wallSurfaceMass , Vector3D caseLimitMin, Vector3D caseLimitMax , bool forceVerticalCaseOrientation) { NoWalls = noWalls; _wallThickness = wallThickness; _wallSurfaceMass = wallSurfaceMass; _caseLimitMin = caseLimitMin; _caseLimitMax = caseLimitMax; _forceVerticalCaseOrientation = forceVerticalCaseOrientation; }
static void Main(string[] args) { BoxProperties bProperties = new BoxProperties(null, 1000, 750, 500); Box b = new Box(0, bProperties); Vector3D vNear = new Vector3D(400.0, 1000.0, 0.0); Vector3D vFar = new Vector3D(500.0, -1000.0, 250.0); Ray r = new Ray(vNear, vFar); Vector3D ptInter; if (b.RayIntersect(r, out ptInter)) Console.WriteLine("Point inter : {0}", ptInter); else Console.WriteLine("No intersection found"); }
public void TestIsPointBehind() { Face f = new Face(0, Vector3D.Zero, new Vector3D(100.0, 0.0, 0.0), new Vector3D(100.0, 0.0, 100.0), new Vector3D(0.0, 0.0, 100.0)); Vector3D viewDir0 = new Vector3D(1.0, 1.0, -1.0); Assert.True(f.PointIsBehind(new Vector3D(50.0, 100.0, 50.0), viewDir0)); Assert.False(f.PointIsBehind(new Vector3D(50.0, -100.0, 50.0), viewDir0)); Vector3D viewDir1 = new Vector3D(-1.0, 1.0, -1.0); Assert.True(f.PointIsBehind(new Vector3D(50.0, 100.0, 50.0), viewDir1)); Assert.False(f.PointIsBehind(new Vector3D(50.0, -100.0, 50.0), viewDir1)); Vector3D viewDir2 = new Vector3D(-1.0, -1.0, -1.0); Assert.False(f.PointIsBehind(new Vector3D(50.0, 100.0, 50.0), viewDir2)); Assert.True(f.PointIsBehind(new Vector3D(50.0, -100.0, 50.0), viewDir2)); Vector3D viewDir3 = new Vector3D(1.0, -1.0, -1.0); Assert.False(f.PointIsBehind(new Vector3D(50.0, 100.0, 50.0), viewDir3)); Assert.True(f.PointIsBehind(new Vector3D(50.0, -100.0, 50.0), viewDir3)); }
// static methods static public double EstimateWeight( BoxProperties boxProperties, PackArrangement arrangement, HalfAxis.HAxis orientation , int[] noWalls, double thickness, double surfacicMass) { double length = 0.0, width = 0.0, height = 0.0; PackProperties.GetDimensions(boxProperties, orientation, arrangement, ref length, ref width, ref height); Vector3D vDimensions = new Vector3D( length + noWalls[0] * thickness , width + noWalls[1] * thickness , height + noWalls[2] * thickness); double area = (noWalls[0] * vDimensions.Y * vDimensions.Z + noWalls[1] * vDimensions.X * vDimensions.Z + noWalls[2] * vDimensions.X * vDimensions.Y) * UnitsManager.FactorSquareLengthToArea; return area * surfacicMass; }
public static HAxis ToHalfAxis(Vector3D v) { const double eps = 1.0E-03; v.Normalize(); if (Math.Abs(Vector3D.DotProduct(v, -Vector3D.XAxis) - 1) < eps) return HAxis.AXIS_X_N; else if (Math.Abs(Vector3D.DotProduct(v, Vector3D.XAxis) - 1) < eps) return HAxis.AXIS_X_P; else if (Math.Abs(Vector3D.DotProduct(v, -Vector3D.YAxis) - 1) < eps) return HAxis.AXIS_Y_N; else if (Math.Abs(Vector3D.DotProduct(v, Vector3D.YAxis) - 1) < eps) return HAxis.AXIS_Y_P; else if (Math.Abs(Vector3D.DotProduct(v, -Vector3D.ZAxis) - 1) < eps) return HAxis.AXIS_Z_N; else return HAxis.AXIS_Z_P; }
public void MinMax(double boxLength, double boxWidth, out Vector2D vMin, out Vector2D vMax) { Vector3D[] pts = new Vector3D[4]; pts[0] = new Vector3D(_position.X, _position.Y, 0.0); pts[1] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_lengthAxis) * boxLength; pts[2] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_widthAxis) * boxWidth; pts[3] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_lengthAxis) * boxLength + HalfAxis.ToVector3D(_widthAxis) * boxWidth; vMin = new Vector2D(double.MaxValue, double.MaxValue); vMax = new Vector2D(double.MinValue, double.MinValue); foreach (Vector3D v in pts) { vMin.X = Math.Min(v.X, vMin.X); vMin.Y = Math.Min(v.Y, vMin.Y); vMax.X = Math.Max(v.X, vMax.X); vMax.Y = Math.Max(v.Y, vMax.Y); } }
public BBox3D BBox(double radius, double length) { Transform3D t = Transf; Vector3D[] pts = new Vector3D[] { new Vector3D(0.0, -radius, -radius), new Vector3D(0.0, -radius, radius), new Vector3D(0.0, radius, -radius), new Vector3D(0.0, radius, radius), new Vector3D(length, -radius, -radius), new Vector3D(length, -radius, radius), new Vector3D(length, radius, -radius), new Vector3D(length, radius, radius) }; BBox3D bbox = new BBox3D(); foreach (Vector3D pt in pts) bbox.Extend(t.transform(pt)); return bbox; }
bool RayIntersect(Ray ray, out uint id, out uint layerId, out Vector3D v) { id = 0; layerId = 0; v = new Vector3D(); List<PickResult> results = new List<PickResult>(); foreach (PickItem item in _items) { Vector3D ptInter; if (item.Box.RayIntersect(ray, out ptInter)) { results.Add(new PickResult()); } } results.Sort(); return results.Count > 0; }
public void AddPosition(CylLoad load, CylPosition pos) { Matrix4D matRot = Matrix4D.Identity; Vector3D vTranslation = Vector3D.Zero; if (_swapped) { matRot = new Matrix4D( 0.0, -1.0, 0.0, 0.0 , 1.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 1.0 ); vTranslation = new Vector3D(load.PalletLength, 0.0, 0.0); matRot.M14 = vTranslation[0]; matRot.M24 = vTranslation[1]; matRot.M34 = vTranslation[2]; } load.Add(pos.Transform(new Transform3D(matRot))); }
public static Vector3D ConvertLengthFrom(Vector3D value, UnitsManager.UnitSystem unitSystem) { if (unitSystem == CurrentUnitSystem) return value; else { StandardMeasure<Length> measureX = new StandardMeasure<Length>(value.X, LengthUnitFromUnitSystem(unitSystem)); StandardMeasure<Length> measureY = new StandardMeasure<Length>(value.Y, LengthUnitFromUnitSystem(unitSystem)); StandardMeasure<Length> measureZ = new StandardMeasure<Length>(value.Z, LengthUnitFromUnitSystem(unitSystem)); return new Vector3D( measureX.GetAmount(LengthUnitFromUnitSystem(CurrentUnitSystem)) , measureY.GetAmount(LengthUnitFromUnitSystem(CurrentUnitSystem)) , measureZ.GetAmount(LengthUnitFromUnitSystem(CurrentUnitSystem)) ); } }
public BoxPosition(Vector3D vPosition, HalfAxis.HAxis dirLength, HalfAxis.HAxis dirWidth) { _vPosition = vPosition; _axisLength = dirLength; _axisWidth = dirWidth; }
private BoxPosition GetPosition(int i, int j, int k, int dim0, int dim1) { double boxLength = _caseDefinition.BoxLength(_boxProperties); double boxWidth = _caseDefinition.BoxWidth(_boxProperties); double boxHeight = _caseDefinition.BoxHeight(_boxProperties); HalfAxis.HAxis dirLength = HalfAxis.HAxis.AXIS_X_P; HalfAxis.HAxis dirWidth = HalfAxis.HAxis.AXIS_Y_P; Vector3D vPosition = Vector3D.Zero; if (0 == dim0 && 1 == dim1) { dirLength = HalfAxis.HAxis.AXIS_X_P; dirWidth = HalfAxis.HAxis.AXIS_Y_P; vPosition = Vector3D.Zero; } else if (0 == dim0 && 2 == dim1) { dirLength = HalfAxis.HAxis.AXIS_X_P; dirWidth = HalfAxis.HAxis.AXIS_Z_N; vPosition = new Vector3D(0.0, 0.0, _boxProperties.Width); } else if (1 == dim0 && 0 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Y_P; dirWidth = HalfAxis.HAxis.AXIS_X_N; vPosition = new Vector3D(_boxProperties.Width, 0.0, 0.0); } else if (1 == dim0 && 2 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Z_N; dirWidth = HalfAxis.HAxis.AXIS_X_P; vPosition = new Vector3D(0.0, _boxProperties.Height, _boxProperties.Length); } else if (2 == dim0 && 0 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Y_P; dirWidth = HalfAxis.HAxis.AXIS_Z_N; vPosition = new Vector3D(_boxProperties.Height, 0.0, _boxProperties.Width); } else if (2 == dim0 && 1 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Z_P; dirWidth = HalfAxis.HAxis.AXIS_Y_P; vPosition = new Vector3D(_boxProperties.Height, 0.0, 0.0); } // add wall thickness vPosition += new Vector3D( _caseOptimConstraintSet.NoWalls[0] * _caseOptimConstraintSet.WallThickness * 0.5 , _caseOptimConstraintSet.NoWalls[1] * _caseOptimConstraintSet.WallThickness * 0.5 , _caseOptimConstraintSet.NoWalls[2] * _caseOptimConstraintSet.WallThickness * 0.5); // apply global transformation using _dir0 / _dir1 return BoxPosition.Transform( new BoxPosition(vPosition + new Vector3D(i * boxLength, j * boxWidth, k * boxHeight), dirLength, dirWidth) , GlobalTransformation ); }
private Point[] TransformPoint(Vector3D[] points3d) { float aspectRatio = (float)Size.Width / ((float)Size.Height * _numberOfViews); float viewportRatio = (_viewport[2] - _viewport[0]) / (_viewport[3] - _viewport[1]); float margin = 0.1f * (_viewport[2] - _viewport[0]); Point[] points = new Point[points3d.Length]; int i=0; foreach (Vector3D v in points3d) { if (viewportRatio > aspectRatio) { points[i].X = (int) ( (float)(Size.Width / _numberOfViews) * (_iIndexView + (v.X - _viewport[0] + margin) / (_viewport[2] - _viewport[0] + 2.0f * margin)) ); points[i].Y = (int) ( Size.Height * aspectRatio / viewportRatio * (v.Y - _viewport[1] + margin) / (_viewport[3] - _viewport[1] + 2.0f * margin) ); } else { points[i].X = (int) ( (float)(Size.Width / _numberOfViews) * (_iIndexView + (viewportRatio / aspectRatio) * (v.X - _viewport[0] + margin) / (_viewport[2] - _viewport[0] + 2.0f * margin)) ); points[i].Y = (int) ( Size.Height * (v.Y - _viewport[1] + margin) / (_viewport[3] - _viewport[1] + 2.0f * margin) ); } ++i; } return points; }
BoxPosition GetPosition(int i, int j, int k, int dim0, int dim1) { BoxProperties boxProperties = _packProperties.Box; double boxLength = boxProperties.Dim(dim0); double boxWidth = boxProperties.Dim(dim1); double boxHeight = boxProperties.Dim(3 - dim0 - dim1); HalfAxis.HAxis dirLength = HalfAxis.HAxis.AXIS_X_P; HalfAxis.HAxis dirWidth = HalfAxis.HAxis.AXIS_Y_P; Vector3D vPosition = Vector3D.Zero; if (0 == dim0 && 1 == dim1) { dirLength = HalfAxis.HAxis.AXIS_X_P; dirWidth = HalfAxis.HAxis.AXIS_Y_P; vPosition = Vector3D.Zero; } else if (0 == dim0 && 2 == dim1) { dirLength = HalfAxis.HAxis.AXIS_X_P; dirWidth = HalfAxis.HAxis.AXIS_Z_N; vPosition = new Vector3D(0.0, 0.0, boxProperties.Width); } else if (1 == dim0 && 0 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Y_P; dirWidth = HalfAxis.HAxis.AXIS_X_N; vPosition = new Vector3D(boxProperties.Width, 0.0, 0.0); } else if (1 == dim0 && 2 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Z_N; dirWidth = HalfAxis.HAxis.AXIS_X_P; vPosition = new Vector3D(0.0, boxProperties.Height, boxProperties.Length); } else if (2 == dim0 && 0 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Y_P; dirWidth = HalfAxis.HAxis.AXIS_Z_N; vPosition = new Vector3D(boxProperties.Height, 0.0, boxProperties.Width); } else if (2 == dim0 && 1 == dim1) { dirLength = HalfAxis.HAxis.AXIS_Z_P; dirWidth = HalfAxis.HAxis.AXIS_Y_P; vPosition = new Vector3D(boxProperties.Height, 0.0, 0.0); } // add offset vPosition += Vector3D.Zero; Vector3D vOffset = new Vector3D( 0.5 * (_packProperties.Length - _packProperties.InnerLength) , 0.5 * (_packProperties.Width - _packProperties.InnerWidth) , 0.5 * (_packProperties.Height - _packProperties.InnerHeight) ); // apply global transformation using _dir0 / _dir1 return BoxPosition.Transform( new BoxPosition( vPosition + vOffset + new Vector3D(i * boxLength, j * boxWidth, k * boxHeight) , dirLength , dirWidth) , GlobalTransformation ); }