Update rendering code
git-svn-id: https://triangle.svn.codeplex.com/svn@75115 0e2699bc-83d4-4a8f-98e7-55e24ab8c7a5
This commit is contained in:
@@ -619,7 +619,7 @@ namespace MeshExplorer
|
||||
this.voronoi = new SimpleVoronoi(mesh);
|
||||
}
|
||||
|
||||
renderManager.Set(voronoi, false);
|
||||
renderManager.Set(voronoi.Points, voronoi.Edges, false);
|
||||
}
|
||||
|
||||
private void ShowLog()
|
||||
|
||||
@@ -104,7 +104,15 @@ namespace TriangleNet.Rendering.GDI
|
||||
|
||||
private void RenderVoronoi(IRenderLayer layer)
|
||||
{
|
||||
meshRenderer.RenderEdges(layer.Points.Data, layer.Indices.Data, Context.ColorManager.VoronoiLine);
|
||||
if (RenderManager.VORONOI_DEBUG)
|
||||
{
|
||||
meshRenderer.RenderEdges(layer.Points.Data, layer.Indices.Data, Pens.Purple);
|
||||
meshRenderer.RenderPoints(layer.Points.Data, layer.Points.Size, 0, layer.Count, Brushes.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
meshRenderer.RenderEdges(layer.Points.Data, layer.Indices.Data, Context.ColorManager.VoronoiLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace TriangleNet.Rendering
|
||||
|
||||
void Add(IPolygon data);
|
||||
void Add(IMesh data, bool reset);
|
||||
void Add(IVoronoi voronoi, bool reset);
|
||||
void Add(Point[] points, IEnumerable<IEdge> edges, bool reset);
|
||||
|
||||
void Add(float[] values);
|
||||
void Add(int[] partition);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
|
||||
namespace TriangleNet.Rendering
|
||||
{
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using TriangleNet.Geometry;
|
||||
using TriangleNet.Meshing;
|
||||
using TriangleNet.Rendering.Buffer;
|
||||
using TriangleNet.Rendering.Util;
|
||||
using TriangleNet.Voronoi.Legacy;
|
||||
|
||||
using Color = System.Drawing.Color;
|
||||
|
||||
public interface IRenderLayer
|
||||
{
|
||||
@@ -25,11 +26,11 @@ namespace TriangleNet.Rendering
|
||||
BoundingBox SetPoints(IBuffer<float> buffer);
|
||||
BoundingBox SetPoints(IPolygon poly);
|
||||
BoundingBox SetPoints(IMesh mesh);
|
||||
BoundingBox SetPoints(IVoronoi voronoi);
|
||||
BoundingBox SetPoints(Point[] points);
|
||||
void SetPolygon(IPolygon poly);
|
||||
void SetPolygon(IMesh mesh);
|
||||
void SetMesh(IMesh mesh, bool elements);
|
||||
void SetMesh(IVoronoi voronoi);
|
||||
void SetMesh(IEnumerable<IEdge> edges);
|
||||
|
||||
|
||||
// TODO: better put these into a subclass.
|
||||
|
||||
@@ -117,11 +117,10 @@ namespace TriangleNet.Rendering
|
||||
RenderLayers[3].IsActive = true;
|
||||
}
|
||||
|
||||
// Voronoi
|
||||
public void Add(IVoronoi voronoi, bool reset)
|
||||
public void Add(Point[] points, IEnumerable<IEdge> edges, bool reset)
|
||||
{
|
||||
RenderLayers[4].SetPoints(voronoi);
|
||||
RenderLayers[4].SetMesh(voronoi);
|
||||
RenderLayers[4].SetPoints(points);
|
||||
RenderLayers[4].SetMesh(edges);
|
||||
RenderLayers[4].IsActive = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
|
||||
namespace TriangleNet.Rendering
|
||||
{
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using TriangleNet.Geometry;
|
||||
using TriangleNet.Meshing;
|
||||
using TriangleNet.Rendering.Buffer;
|
||||
using TriangleNet.Rendering.Util;
|
||||
using TriangleNet.Voronoi.Legacy;
|
||||
|
||||
using Color = System.Drawing.Color;
|
||||
|
||||
public class RenderLayer : IRenderLayer
|
||||
{
|
||||
@@ -107,11 +108,11 @@ namespace TriangleNet.Rendering
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public BoundingBox SetPoints(IVoronoi voronoi)
|
||||
public BoundingBox SetPoints(Point[] vertices)
|
||||
{
|
||||
BoundingBox bounds = new BoundingBox();
|
||||
|
||||
points = BufferHelper.CreateVertexBuffer(voronoi.Points, ref bounds);
|
||||
points = BufferHelper.CreateVertexBuffer(vertices, ref bounds);
|
||||
count = points.Count / points.Size;
|
||||
|
||||
return bounds;
|
||||
@@ -127,9 +128,9 @@ namespace TriangleNet.Rendering
|
||||
indices = BufferHelper.CreateIndexBuffer(mesh.Segments, 2);
|
||||
}
|
||||
|
||||
public void SetMesh(IVoronoi voronoi)
|
||||
public void SetMesh(IEnumerable<IEdge> edges)
|
||||
{
|
||||
indices = BufferHelper.CreateIndexBuffer(voronoi.Edges, 2);
|
||||
indices = BufferHelper.CreateIndexBuffer(edges, 2);
|
||||
}
|
||||
|
||||
public void SetMesh(IMesh mesh, bool elements)
|
||||
|
||||
@@ -7,10 +7,12 @@ namespace TriangleNet.Rendering
|
||||
using TriangleNet.Meshing;
|
||||
using TriangleNet.Rendering.GDI;
|
||||
using TriangleNet.Rendering.Util;
|
||||
using TriangleNet.Voronoi.Legacy;
|
||||
|
||||
public class RenderManager
|
||||
{
|
||||
// TODO: delete
|
||||
public static bool VORONOI_DEBUG = false;
|
||||
|
||||
IRenderControl control;
|
||||
IRenderContext context;
|
||||
IRenderer renderer;
|
||||
@@ -112,10 +114,12 @@ namespace TriangleNet.Rendering
|
||||
}
|
||||
}
|
||||
|
||||
// Voronoi
|
||||
public void Set(IVoronoi voronoi, bool reset, bool refresh = true)
|
||||
/// <summary>
|
||||
/// Set data for Voronoi layer.
|
||||
/// </summary>
|
||||
public void Set(Point[] points, IEnumerable<IEdge> edges, bool reset, bool refresh = true)
|
||||
{
|
||||
context.Add(voronoi, reset);
|
||||
context.Add(points, edges, reset);
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user