public virtual ParameterObjectData GetParameterObjectData(string colStr, params string[] paramValues) { if (Children == null || Children.Count == 0) { return(new ParameterObjectData(ReplaceNames(xExpr, ParamNames, paramValues), ReplaceNames(yExpr, ParamNames, paramValues), ReplaceNames(zExpr, ParamNames, paramValues), (new ExpressionParser(ReplaceNames(SminExpr, ParamNames, paramValues), null)).runnable(null), (new ExpressionParser(ReplaceNames(SmaxExpr, ParamNames, paramValues), null)).runnable(null), (new ExpressionParser(ReplaceNames(TminExpr, ParamNames, paramValues), null)).runnable(null), (new ExpressionParser(ReplaceNames(TmaxExpr, ParamNames, paramValues), null)).runnable(null), (int)(new ExpressionParser(ReplaceNames(nsExpr, ParamNames, paramValues), null)).runnable(null), (int)(new ExpressionParser(ReplaceNames(ntExpr, ParamNames, paramValues), null)).runnable(null), WrapS, WrapT, colStr)); } else { ParameterObjectData pObjData = new ParameterObjectData(); for (int i = 0; i < Children.Count; i++) { pObjData.Children.Add(Children[i].GetParameterObjectData(colStr, paramValues)); } return(pObjData); } }
public AddImageDialog(ParameterObjectData pOD, GeometryModel3D gm3D) { pObjData = pOD; geomMod3D = gm3D; Ns = pOD.NumFacetS + 1; Nt = pOD.NumFacetT + 1; InitializeComponent(); }
public void AddImageToGeometryModel3D(GeometryModel3D geomMod3D) { MeshGeometry3D meshGeom = (MeshGeometry3D)geomMod3D.Geometry; MaterialGroup materialGroup = (MaterialGroup)geomMod3D.Material; int iBegin = imageIndices[0]; int jBegin = imageIndices[1]; int iEnd = imageIndices[2]; int jEnd = imageIndices[3]; int Ns = NumFacetS + 1; int Nt = NumFacetT + 1; if (iBegin >= iEnd || jBegin >= jEnd) { throw (new Exception("Invalid Index Range")); } meshGeom.TextureCoordinates.Clear(); for (int n = 0; n < meshGeom.Positions.Count; n++) { meshGeom.TextureCoordinates.Add(new Point(-1, -1)); } ImageBrush imgBrush = new ImageBrush(imageSource); imgBrush.ViewportUnits = BrushMappingMode.Absolute; imgBrush.Transform = new MatrixTransform(imageTransformMatrix); if (imageTiled) { imgBrush.TileMode = TileMode.Tile; } else { imgBrush.TileMode = TileMode.None; } for (int i = 0; i < Ns; i++) { for (int j = 0; j < Nt; j++) { meshGeom.TextureCoordinates[ParameterObjectData.GetPositionIndex(i, j, Ns, Nt)] = new Point((double)(i - iBegin) / (double)(iEnd - iBegin), (double)(j - jBegin) / (double)(jEnd - jBegin)); } } materialGroup.Children[1] = new DiffuseMaterial(imgBrush); }
private void okButton_Click(object sender, RoutedEventArgs e) { double dim1 = 0, dim2 = 0, dim3 = 0; ParameterObjectData pobj = null; string xf, yf, zf; string colStr = (string)comboBoxColor.SelectedItem; try { dim1 = double.Parse(tbxDimension1.Text); if (dim1 <= 0) { throw new Exception("Invalid dimension 1"); } if (tbxDimension2.IsVisible) { dim2 = double.Parse(tbxDimension2.Text); if (dim2 <= 0) { throw new Exception("Invalid dimension 2"); } } if (tbxDimension3.IsVisible) { dim3 = double.Parse(tbxDimension3.Text); if (dim3 <= 0) { throw new Exception("Invalid dimension 3"); } } } catch (Exception except) { MessageBox.Show("Error parsing shape input: " + except.Message); Tag = null; DialogResult = false; return; } if (shapeName == "Sphere") { xf = dim1.ToString() + "*Cos(s)*Cos(t)"; yf = dim1.ToString() + "*Sin(s)*Cos(t)"; zf = dim1.ToString() + "*Sin(t)"; pobj = new ParameterObjectData(xf, yf, zf, 0, 6.28, -1.57, 1.57, 20, 10, true, false, colStr); } else if (shapeName == "Cylinder") { pobj = new ParameterObjectData(); xf = dim1.ToString() + "*Cos(s)"; yf = dim1.ToString() + "*Sin(s)"; zf = dim2.ToString() + "*t"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, 0, 6.28, -0.5, 0.5, 20, 10, true, false, colStr)); xf = dim1.ToString() + "*t*Cos(s)"; yf = dim1.ToString() + "*t*Sin(s)"; zf = dim2.ToString() + "*0.5"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, 0, 6.28, 1, 0, 20, 5, true, false, colStr)); zf = "-" + dim2.ToString() + "*0.5"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, 0, 6.28, 0, 1, 20, 5, true, false, colStr)); } else if (shapeName == "Block") { pobj = new ParameterObjectData(); xf = dim1.ToString() + "*s"; yf = dim2.ToString() + "*t"; zf = dim3.ToString() + "*0.5"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, -0.5, 0.5, 10, 10, false, false, colStr)); zf = "-" + dim3.ToString() + "*0.5"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, 0.5, -0.5, 10, 10, false, false, colStr)); xf = dim1.ToString() + "*0.5"; yf = dim2.ToString() + "*s"; zf = dim3.ToString() + "*t"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, -0.5, 0.5, 10, 10, false, false, colStr)); xf = "-" + dim1.ToString() + "*0.5"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, 0.5, -0.5, 10, 10, false, false, colStr)); xf = dim1.ToString() + "*t"; yf = dim2.ToString() + "*0.5"; zf = dim3.ToString() + "*s"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, -0.5, 0.5, 10, 10, false, false, colStr)); yf = "-" + dim2.ToString() + "*0.5"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, 0.5, -0.5, 10, 10, false, false, colStr)); } else if (shapeName == "Donut") { xf = "Cos(s) * (" + dim1.ToString() + "+" + dim2.ToString() + "*Cos(t))"; yf = "Sin(s) * (" + dim1.ToString() + "+" + dim2.ToString() + "*Cos(t))"; zf = dim2.ToString() + "*Sin(t)"; pobj = new ParameterObjectData(xf, yf, zf, 0, 6.28, 0, 6.28, 20, 10, true, true, colStr); } else if (shapeName == "Cone") { pobj = new ParameterObjectData(); xf = dim1.ToString() + "* Cos(s) * (0.5 - t)"; yf = dim1.ToString() + "* Sin(s) * (0.5 - t)"; zf = dim2.ToString() + "* t"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, 0, 6.28, -0.5, 0.5, 20, 10, true, false, colStr)); xf = dim1.ToString() + "*t*Cos(s)"; yf = dim1.ToString() + "*t*Sin(s)"; zf = "-" + dim2.ToString() + "*0.5"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, 0, 6.28, 0, 1, 20, 5, true, false, colStr)); } else if (shapeName == "Pyramid") { pobj = new ParameterObjectData(); xf = dim1.ToString() + "*s"; yf = dim2.ToString() + "*t"; zf = "-" + dim3.ToString() + "*0.5"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, 0.5, -0.5, 10, 10, false, false, colStr)); xf = dim1.ToString() + "* s * (0.5 - t)"; yf = "0.5 * " + dim2.ToString() + " * (t-0.5)"; zf = dim3.ToString() + "* t"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, -0.5, 0.5, 5, 5, false, false, colStr)); yf = "-0.5 * " + dim2.ToString() + " * (t-0.5)"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, 0.5, -0.5, 5, 5, false, false, colStr)); xf = "0.5 * " + dim1.ToString() + " * (t - 0.5)"; yf = dim2.ToString() + "* s * (0.5 - t)"; zf = dim3.ToString() + " * t"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, 0.5, -0.5, 5, 5, false, false, colStr)); xf = "-0.5 * " + dim1.ToString() + " * (t - 0.5)"; pobj.Children.Add(new ParameterObjectData(xf, yf, zf, -0.5, 0.5, -0.5, 0.5, 5, 5, false, false, colStr)); } else { Tag = null; DialogResult = false; return; } Tag = pobj; DialogResult = true; }