title: Create (or extrude) a 3D Polygon from a 2D Polygon - C# WPF Helix Toolkit
body: <p>I'm working on a WPF project that displays a 2D city area.
  I have 2D polygons that represent buildings.</p>
  
  <p>In order to have a 3D view, I need to transform these buildings into 3D polygons, by "extruding" them from the base area. I chose Helix Toolkit, that seemed appropriate for what I want.</p>
  
  <p>Thanks to the large documentation of Helix Toolkit and its helpful examples (that's irony), I tried to "extrude" or triangulate my base polygons to make them 3D.</p>
  
  <p>But the only results I get are some pieces of triangle, or incomplete 3D polygon. There are so many ways to make the same thing in Helix Toolkit that I can't identify what I really need.</p>
  
  <p><a href="https://i.stack.imgur.com/SU4IZ.png" rel="nofollow noreferrer">Here's what I get</a> | <a href="https://i.stack.imgur.com/xAsvw.png" rel="nofollow noreferrer">Here's what I want</a></p>
  
  <p>I'm currently working this way, and I know it's bad :</p>
  
  <pre><code>// Create a model group
  var modelGroup = new Model3DGroup();
  
  // Create an example polygon 
  HelixToolkit.Wpf.Polygon test = new HelixToolkit.Wpf.Polygon();
  test.Points.Add(new Point(0, 0));
  test.Points.Add(new Point(3, 0));
  test.Points.Add(new Point(2, 1));
  test.Points.Add(new Point(1, 4));
  test.Points.Add(new Point(-2, 1));
  test.Points.Add(new Point(0, 0));
  
  // Create a meshbuilder and add the Polygon to it
  var meshBuilder = new MeshBuilder(false, false);
  meshBuilder.AddPolygon(test.Points);
  
  // Create a mesh from the builder (and freeze it)
  var mesh = meshBuilder.ToMesh(true);
  
  // Then I add it to my model group and set the binding property
  modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Transform = new TranslateTransform3D(2, 0, 0), Material = redMaterial, BackMaterial = insideMaterial });
  
  this.Model = modelGroup;
  </code></pre>
  
  <p>I also created a method to create 3D points from my 2D data :</p>
  
  <pre><code>public void createEdges(HelixToolkit.Wpf.Polygon leP)
      {
  
          for (int i=0; i&lt;= leP.Points.Count-2; i++)
          {
              Point3D p1Sol = new Point3D(leP.Points[i].X, leP.Points[i].Y, 0);
              Point3D p2Sol = new Point3D(leP.Points[i+1].X, leP.Points[i].Y, 0);
              Point3D p1Ciel = new Point3D(leP.Points[i].X, leP.Points[i].Y, 5);
              Point3D p2Ciel = new Point3D(leP.Points[i + 1].X, leP.Points[i].Y, 5);
  
              Faace laFace = new Faace();
  
              laFace.LesPoints.Add(p1Sol);
              laFace.LesPoints.Add(p1Ciel);
              laFace.LesPoints.Add(p2Ciel);
              laFace.LesPoints.Add(p2Sol);
              laFace.LesPoints.Add(p1Sol);
  
  
              lesFaces.Add(laFace);
          }
  
  
      }
  </code></pre>
  
  <p>This method gives the first screenshot I linked.</p>
  
  <p>I spent so many time trying to understand the toolkit, but I'm strongly stuck and would appreciate some help. Is there a way to do it correctly ?</p>
  
  <p>Hoping I've been sufficiently clear.</p>
  
  <p>Thanks by advance,</p>
  
  <p>Martin</p>