private void UpdateVisuals()
        {
            Children.Clear();
            if (WindTurbine == null) return;

            var baseTower = new TruncatedConeVisual3D
                                {
                                    Fill = Brushes.Yellow,
                                    Origin = new Point3D(0, 0, -WindTurbine.BaseHeight)
                                };
            baseTower.Height = -baseTower.Origin.Z + 2;
            baseTower.BaseRadius = baseTower.TopRadius = WindTurbine.Diameter;

            var tower = new TruncatedConeVisual3D
                            {
                                Fill = Brushes.White,
                                Origin = new Point3D(0, 0, 2),
                                Height = WindTurbine.Height,
                                BaseRadius = WindTurbine.Diameter
                            };
            tower.TopRadius = tower.BaseRadius * (1 - WindTurbine.Height * Math.Sin(WindTurbine.ShaftAngle / 180.0 * Math.PI));

            var nacelle = new TruncatedConeVisual3D
                              {
                                  Fill = Brushes.White,
                                  Origin = new Point3D(WindTurbine.Overhang, 0, tower.Origin.Z + tower.Height),
                                  Normal = new Vector3D(-1, 0, 0),
                                  TopRadius = WindTurbine.NacelleDiameter
                              };
            nacelle.BaseRadius = nacelle.TopRadius * 0.7;
            nacelle.Height = WindTurbine.NacelleLength;

            Children.Add(baseTower);
            Children.Add(tower);
            Children.Add(nacelle);


            var endcap = new SphereVisual3D
                             {
                                 Center = new Point3D(WindTurbine.Overhang - WindTurbine.NacelleLength, 0,
                                                      tower.Origin.Z + tower.Height),
                                 Radius = nacelle.TopRadius,
                                 Fill = Brushes.White
                             };
            Children.Add(endcap);

            var rotor = new ModelVisual3D();

            for (int i = 0; i < WindTurbine.Blades; i++)
            {
                double angle = (double)i / WindTurbine.Blades * Math.PI * 2;

                // todo: the blade is simplified to a cone... it should be a real profile...
                var blade = new TruncatedConeVisual3D
                                {
                                    Origin = nacelle.Origin,
                                    Normal = new Vector3D(0, Math.Cos(angle), Math.Sin(angle)),
                                    Height = WindTurbine.BladeLength,
                                    BaseRadius = WindTurbine.BladeRootChord,
                                    TopRadius = WindTurbine.BladeTipChord,
                                    Fill = Brushes.White
                                };
                rotor.Children.Add(blade);
            }

            var hub = new SphereVisual3D
                          {
                              Fill = Brushes.White,
                              Center = nacelle.Origin,
                              Radius = WindTurbine.HubDiameter / 2
                          };
            rotor.Children.Add(hub);
            Children.Add(rotor);

            var rotation = new AxisAngleRotation3D(new Vector3D(1, 0, 0), 0);
            var rotorTransform = new RotateTransform3D(null, hub.Center) { Rotation = rotation };
            rotor.Transform = rotorTransform;

            var b = new Binding("RotationAngle") { Source = this };
            BindingOperations.SetBinding(rotation, AxisAngleRotation3D.AngleProperty, b);
        }
Ejemplo n.º 2
0
    public static List<Visual3D> Representation3D(this JupiterWell Well, IXYPoint refpoint)
    {
      List<Visual3D> wellrep = new List<Visual3D>();

      double x = refpoint.X - Well.X;
      double y = refpoint.Y - Well.Y;

      TruncatedConeVisual3D tcvw = new TruncatedConeVisual3D();
      tcvw.TopRadius = 0.5;
      tcvw.BaseRadius = 0.5;
      tcvw.Origin = new System.Windows.Media.Media3D.Point3D(x, y, Well.Terrain - Well.Depth.Value);
      if (Well.Depth.HasValue)
        tcvw.Height = Well.Depth.Value;
      else if (Well.Intakes.SelectMany(var => var.Screens).Count() > 0)
        tcvw.Height = Well.Intakes.SelectMany(var => var.Screens).Max(var2 => var2.DepthToBottom.Value);
      else
        tcvw.Height = Well.LithSamples.Max(var => var.Bottom);

      tcvw.Fill = new SolidColorBrush(Colors.Gray);
      wellrep.Add(tcvw);


      foreach (var sc in Well.Intakes.SelectMany(var => var.Screens))
      {
        if (sc.DepthToBottom.HasValue & sc.DepthToTop.HasValue)
        {
          TruncatedConeVisual3D tcv = new TruncatedConeVisual3D();
          tcv.TopRadius = 0.7;
          tcv.BaseRadius = 0.7;
          tcv.Origin = new System.Windows.Media.Media3D.Point3D(x, y, sc.BottomAsKote.Value);
          tcv.Height = sc.TopAsKote.Value - sc.BottomAsKote.Value;
          tcv.Fill = new SolidColorBrush(Colors.Black);
          wellrep.Add(tcv);
        }
      }

      foreach (var l in Well.LithSamples)
      {
        if (l.Top != -999 & l.Bottom != -999)
        {
          TruncatedConeVisual3D tcv = new TruncatedConeVisual3D();
          tcv.TopRadius = 1;
          tcv.BaseRadius = 1;
          tcv.Origin = new System.Windows.Media.Media3D.Point3D(x, y, Well.Terrain - l.Bottom);
          tcv.Height = l.Bottom - l.Top;
          SolidColorBrush m;
          if (l.RockSymbol.ToLower().Contains("s"))
          {
            m = new SolidColorBrush(Colors.Blue);
          }
          else if (l.RockSymbol.ToLower().Contains("l"))
          {
            m = new SolidColorBrush(Colors.Red);
          }
          else
            m = new SolidColorBrush(Colors.Green);

          m.Opacity = 0.3;
          tcv.Fill = m;

          wellrep.Add(tcv);
          TextVisual3D txt = new TextVisual3D();
          txt.Center = new Point3D(x+3, y+3, Well.Terrain - (l.Bottom + l.Top)/2.0);
          txt.Text = l.RockSymbol;
          txt.Height = 1;
          wellrep.Add(txt);

        }

      }
      return wellrep;
    }