private static MeshGeometry3D CreateGeometry(NewBGCViewModel viewModel) { var startPoint = viewModel.Center - 0.5 * viewModel.Length * viewModel.Axis; var endPoint = viewModel.Center + 0.5 * viewModel.Length * viewModel.Axis; var components = viewModel.Components; ///var path = viewModel.Components. var Ts = (from component in components select component.T).ToArray(); var diameters = (from component in components select 2 * component.Radius).ToArray(); //Construct the 3D Points Point3D[] path = new Point3D[Ts.Length]; for (int i = 0; i < Ts.Length; i++) { path[i] = startPoint + Ts[i] * viewModel.V; } var builder = new MeshBuilder(); builder.AddTube( path, null, diameters, thetaDiv: CIRCLE_DIV, isTubeClosed: false); var geometry = builder.ToMesh(freeze: true); return(geometry); }
public NewBGCView(NewBGCViewModel viewModel, ILoggerFacade logger) : base(viewModel, logger) { this.viewModel = viewModel; viewModel.PropertyChanged += viewModel_PropertyChanged; model = new GeometryModel3D { Geometry = CreateGeometry(viewModel), Material = GetDefaultFrontMaterial(viewModel), BackMaterial = GetDefaultBackMaterial(), }; modelVisual = new ModelVisual3D { Content = model }; Children.Add(modelVisual); }