problem

Apr 4, 2014 at 8:53 PM
Edited Apr 4, 2014 at 9:01 PM
j'ai mis se simple code ,ou est le probleme


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TriangleNet ;
using MeshRenderer;



namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Mesh mesh = new Mesh();
        var g = new MeshRenderer.Core.BoundingBox(150, 150, 150, 150);

        var geometry = new TriangleNet.Geometry.InputGeometry(8);

        // Add the points. 
        geometry.AddPoint(0.5, 0.5); // Index 0
        geometry.AddPoint(0.1, 0.1); // Index 1 etc.
        geometry.AddPoint(3.0, 3.0);
        geometry.AddPoint(0.0, 3.0, 1); // Add a marker.
        geometry.AddPoint(1.0, 1.0);
        geometry.AddPoint(2.0, 1.0);
        geometry.AddPoint(2.0, 2.0);
        geometry.AddPoint(1.0, 2.0);


        geometry.AddSegment(0, 1);
        geometry.AddSegment(1, 2);
        geometry.AddSegment(2, 3, 5); // Add a marker.
        geometry.AddSegment(3, 0, 5);
        geometry.AddSegment(4, 5);
        geometry.AddSegment(5, 6);
        geometry.AddSegment(6, 7);
        geometry.AddSegment(7, 4);


        geometry.AddHole(1.5, 1.5);








         var i= new  MeshRenderer.Core.ColorManager() ;

            var j= new MeshRenderer.Core.RenderData();

            j.SetInputGeometry(geometry);

            i = MeshRenderer.Core.ColorManager.Default();
          var c=  new MeshRenderer.Core.GDI.MeshRenderer(j, i);
        var d=new MeshRenderer.Core.Zoom() ;
        d.Initialize(new Rectangle(150,150,150,150));

          System.Drawing.Graphics formGraphics = this.CreateGraphics();



          c.RenderGeometry(formGraphics,d   );































    }


}
}
Coordinator
Apr 5, 2014 at 2:56 PM
Edited Apr 5, 2014 at 5:32 PM
First: please don't create a new thread for every question you have (at least if the topic stays the same). Just use this discussion. I deleted some of your previous posts.

Actually, the code above is mostly right, just a few things:
d.Initialize(new Rectangle(150,150,150,150));
will set the dimension of the render target (position (x=150, y=150), width 150, height 150). But you also have to set the dimensions of the data:
d.Update(j.Bounds);
Next, I would not recommend rendering directly to the form (using this.CreateGraphics()). Here's some code that should work, using a bitmap:
Bitmap bitmap;

private void button1_Click(object sender, EventArgs e)
{
    if (bitmap == null)
    {
        bitmap = new Bitmap(150, 150);
    }

    //var mesh = new TriangleNet.Mesh();

    var geometry = new TriangleNet.Geometry.InputGeometry(8);

    // Add the points. 
    geometry.AddPoint(0.0, 0.0); // Index 0
    geometry.AddPoint(3.0, 0.0); // Index 1 etc.
    geometry.AddPoint(3.0, 3.0);
    geometry.AddPoint(0.0, 3.0, 1); // Add a marker.
    geometry.AddPoint(1.0, 1.0);
    geometry.AddPoint(2.0, 1.0);
    geometry.AddPoint(2.0, 2.0);
    geometry.AddPoint(1.0, 2.0);

    geometry.AddSegment(0, 1);
    geometry.AddSegment(1, 2);
    geometry.AddSegment(2, 3, 5); // Add a marker.
    geometry.AddSegment(3, 0, 5);
    geometry.AddSegment(4, 5);
    geometry.AddSegment(5, 6);
    geometry.AddSegment(6, 7);
    geometry.AddSegment(7, 4);

    geometry.AddHole(1.5, 1.5);

    var colors = MeshRenderer.Core.ColorManager.Default();
    var data = new MeshRenderer.Core.RenderData();

    data.SetInputGeometry(geometry);

    var renderer = new MeshRenderer.Core.GDI.MeshRenderer(data, colors);
    var zoom = new MeshRenderer.Core.Zoom();
    zoom.Initialize(new Rectangle(0, 0, bitmap.Width, bitmap.Height));
    zoom.Update(data.Bounds);

    using (var g = Graphics.FromImage(bitmap))
    {
        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        g.Clear(Color.Black);

        renderer.RenderGeometry(g, zoom);

        this.Invalidate();
    }
}

protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    if (bitmap != null)
    {
        e.Graphics.DrawImageUnscaled(bitmap, 50, 50);
    }
}
Apr 5, 2014 at 6:17 PM
merci beaucoup
je m'excuse pour le derrangement