public BasicSurface(SurfaceProperties properties, Vector4 translation = new Vector4()) { _countU = properties.CountU; _countV = properties.CountV; _isTube = properties.IsTube; ParameterRange = new bool[ParameterRangePrecision + 1, ParameterRangePrecision + 1]; for (int i = 0; i < ParameterRangePrecision + 1; i++) { for (int j = 0; j < ParameterRangePrecision + 1; j++) { ParameterRange[i, j] = true; } } if (_countU < 1 || _countV < 1) { return; } if (!_isTube) { var scaleU = properties.SizeU / (_countU * 3); var scaleV = properties.SizeV / (_countV * 3); for (int i = 0; i < _countU * 3 + 1; i++) { for (int j = 0; j < _countV * 3 + 1; j++) { _points.Add(new DrawablePoint(i * scaleU, 0, j * scaleV)); } } if (_countV == 1 && _countV == 1) { _points[0].IsCorner = true; _points[3].IsCorner = true; _points[12].IsCorner = true; _points[15].IsCorner = true; } } else { var scaleU = properties.SizeU / (_countU * 3); var scaleV = (float)Math.PI * 2 / (_countV * 3); for (int i = 0; i < _countU * 3 + 1; i++) { for (int j = 0; j < _countV * 3; j++) { _points.Add(new DrawablePoint((float)Math.Cos(j * scaleV) * properties.SizeV, (float)Math.Sin(j * scaleV) * properties.SizeV, i * scaleU)); } } } _points.ForEach(x => x.Point = x.Point + translation); }
public BSplineSurface(SurfaceProperties properties) { _countU = properties.CountU + 3; _countV = properties.CountV + 3; _isTube = properties.IsTube; if (_countU < 4 || _countV < 4) { MessageBox.Show("Cannot make a Bspline surface with no patch."); return; } ParameterRange = new bool[ParameterRangePrecision + 1, ParameterRangePrecision + 1]; for (int i = 0; i < ParameterRangePrecision + 1; i++) { for (int j = 0; j < ParameterRangePrecision + 1; j++) { ParameterRange[i, j] = true; } } if (!_isTube) { var scaleU = properties.SizeU / _countU; var scaleV = properties.SizeV / _countV; for (int i = 0; i < _countU; i++) { for (int j = 0; j < _countV; j++) { _points.Add(new DrawablePoint(i * scaleU, 0, j * scaleV)); } } } else { var scaleU = properties.SizeU / _countU; var scaleV = (float)Math.PI * 2 / _countV; for (int i = 0; i < _countU; i++) { for (int j = 0; j < _countV; j++) { _points.Add(new DrawablePoint(properties.SizeV * (float)Math.Cos(j * scaleV), properties.SizeV * (float)Math.Sin(j * scaleV), i * scaleU)); } } } }