Esempio n. 1
0
        private void DrawBody(BodyModel model)
        {
            if (model == null)
            {
                throw new ArgumentException();
            }

            var geometry = new MeshGeometry3D();

            _meshService.Reset();
            _meshService.Xs  = model.X;
            _meshService.Ys  = model.Y;
            _meshService.Z1s = model.UpperZ;
            _meshService.Z2s = model.LowerZ;

            geometry.Positions = (Point3DCollection) new Point3DCollectionConverter().ConvertFromString(_meshService.CalculatePositions());
            var triangleIndices = _meshService.CalculateTriangleIndices();

            for (var i = 0; i < triangleIndices.Count(); i++)
            {
                geometry.TriangleIndices.Add(triangleIndices[i]);
            }

            GeometryGroup.Add(new GeometryModel3D
            {
                Geometry = geometry,
                Material = new DiffuseMaterial(Brushes.PaleVioletRed)
            });

            Volume = _meshService.Volume();

            OnPropertyChanged(nameof(GeometryGroup));
        }
Esempio n. 2
0
        public OilBodyViewModel(IThreeDimensionsMeshService meshService, IEventAggregator eventAggregator)
        {
            // inject services
            _meshService = meshService;
            eventAggregator.GetEvent <RequestBodyDrawEvent>().Subscribe(DrawBody);

            // add light to the geometry
            GeometryGroup.Add(new DirectionalLight {
                Direction = new Vector3D(-1, -1, -1)
            });
            GeometryGroup.Add(new DirectionalLight {
                Direction = new Vector3D(-1, -1, 1)
            });

            // initialize converters list
            foreach (var unitValue in Enum.GetValues(typeof(VolumeUnits)))
            {
                var unit = (VolumeUnits)unitValue;
                UnitsList.Add(unit, unit.ToString());
            }
        }