Compare commits
16
Commits
f83f8b9fb1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a03aa1c1ff | ||
|
|
46bfea4a87 | ||
|
|
734ed008b0 | ||
|
|
1b834cff0d | ||
|
|
7d79db5685 | ||
|
|
060fb66029 | ||
|
|
6571576eaa | ||
|
|
f4ec31806b | ||
|
|
2cf5d31bf6 | ||
|
|
40214ca6f4 | ||
|
|
b27c36acb8 | ||
|
|
65a8cce19e | ||
|
|
04bffeccaf | ||
|
|
7beb671352 | ||
|
|
7ed5372805 | ||
|
|
73bcf2802b |
@@ -0,0 +1,53 @@
|
|||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Geom;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Sample.Disp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates the creation and visualization of <see cref="Cylindroid"/> objects.
|
||||||
|
/// Includes examples of building a <see cref="Cylindroid"/> programmatically with
|
||||||
|
/// <see cref="PairZr"/> points and serializing/deserializing via XML.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoCylindroid.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public static class DemoCylindroid
|
||||||
|
{
|
||||||
|
internal static void BuildCylindorid()
|
||||||
|
{
|
||||||
|
Cylindroid cylindroid = new Cylindroid(
|
||||||
|
new PairZr(0, 1),
|
||||||
|
new PairZr(1, 1),
|
||||||
|
new PairZr(1, 2),
|
||||||
|
new PairZr(2, 2),
|
||||||
|
new PairZr(8, 3));
|
||||||
|
|
||||||
|
DispEngine.Init();
|
||||||
|
DemoUtil.Present("BuildCylindorid", cylindroid.ToFaceDrawing());
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void TestCylindoridXml()
|
||||||
|
{
|
||||||
|
Cylindroid cylindroid = new Cylindroid(
|
||||||
|
new PairZr(0, 1),
|
||||||
|
new PairZr(1, 1),
|
||||||
|
new PairZr(1, 2),
|
||||||
|
new PairZr(2, 2),
|
||||||
|
new PairZr(4, 3));
|
||||||
|
var xmlElement = cylindroid.MakeXmlSource(null, null, true);
|
||||||
|
Console.WriteLine("XML:" + xmlElement);
|
||||||
|
|
||||||
|
cylindroid = new Cylindroid(xmlElement);
|
||||||
|
DispEngine.Init();
|
||||||
|
DemoUtil.Present("BuildCylindorid", cylindroid.ToFaceDrawing());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
BuildCylindorid();
|
||||||
|
//TestCylindoridXml();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Disp.Flag;
|
||||||
|
using Hi.Geom;
|
||||||
|
using Hi.Coloring;
|
||||||
|
|
||||||
|
namespace Sample.Disp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates the use of discrete RGB colors for rendering multiple objects.
|
||||||
|
/// Shows how to apply different colors to similar geometric shapes using the
|
||||||
|
/// <see cref="ColorUtil.GetDiscreteRGB_Env"/> method from <see cref="ColorUtil"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoDiscreteRgb.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public class DemoDiscreteRgb : IDisplayee
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
bind.Rgb = ColorUtil.GetDiscreteRGB_Env();
|
||||||
|
new box3d_t(0, 0, 0, 1, 1, 1).ToDraw_Face().Display(bind);
|
||||||
|
|
||||||
|
bind.Rgb = ColorUtil.GetDiscreteRGB_Env();
|
||||||
|
new box3d_t(1, 0, 0, 2, 1, 1).ToDraw_Face().Display(bind);
|
||||||
|
|
||||||
|
bind.Rgb = ColorUtil.GetDiscreteRGB_Env();
|
||||||
|
new box3d_t(2, 0, 0, 3, 1, 1).ToDraw_Face().Display(bind);
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(ref box3d_t dst)
|
||||||
|
{
|
||||||
|
dst = dst.Expanded(new vec3d_t(0, 0, 0));
|
||||||
|
dst = dst.Expanded(new vec3d_t(3, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
DemoUtil.Present("Demo Discrete I",
|
||||||
|
new DispList(new CoordinateDrawing(), new DemoDiscreteRgb()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
using Hi.Geom;
|
||||||
|
using Hi.Disp;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Hi.Disp.Treat;
|
||||||
|
using Hi.Coloring;
|
||||||
|
|
||||||
|
namespace Sample.Disp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates various drawing techniques using the HiAPI graphics system.
|
||||||
|
/// Provides examples of primitive drawing, attribute specification, and rendering options.
|
||||||
|
/// Includes methods for drawing lines, points, triangles, and other geometric primitives.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoDrawing.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public static class DemoDrawing
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates simple line drawing using raw vertex coordinates.
|
||||||
|
/// Creates a basic line strip from three vertices and displays it using DemoUtil.
|
||||||
|
/// </summary>
|
||||||
|
public static void FreeDrawing()
|
||||||
|
{
|
||||||
|
#region DocSite.FreeDrawing
|
||||||
|
double[] vs =
|
||||||
|
{0,0,0
|
||||||
|
,1,0,0
|
||||||
|
,0,0,1};
|
||||||
|
DemoUtil.Present("EasyDraw"
|
||||||
|
, new Drawing(vs, Stamp.V, GL.GL_LINE_STRIP));
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates various types of line drawing techniques.
|
||||||
|
/// Shows how to create points, line strips, line strips with normals, and colored line strips.
|
||||||
|
/// Illustrates different ways to specify vertex attributes like position, color, and normal.
|
||||||
|
/// </summary>
|
||||||
|
public static void DrawLines()
|
||||||
|
{
|
||||||
|
List<vec3d_t> ps;
|
||||||
|
double[] vs;
|
||||||
|
int n = 10; //vertex num
|
||||||
|
|
||||||
|
////create drawPoints
|
||||||
|
ps = new List<vec3d_t>(n);
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
ps.Add(new vec3d_t(i, 0, 0));
|
||||||
|
vs = new double[ps.Count * 3];
|
||||||
|
for (int i = 0; i < ps.Count; i++)
|
||||||
|
{
|
||||||
|
vs[3 * i] = ps[i].x;
|
||||||
|
vs[3 * i + 1] = ps[i].y;
|
||||||
|
vs[3 * i + 2] = ps[i].z;
|
||||||
|
}
|
||||||
|
|
||||||
|
//V means Vertex
|
||||||
|
Drawing drawPoints = new Drawing(vs, Stamp.V, GL.GL_POINTS);
|
||||||
|
|
||||||
|
////create drawLineStrip
|
||||||
|
vs = new double[ps.Count * 3];
|
||||||
|
for (int i = 0; i < ps.Count; i++)
|
||||||
|
{
|
||||||
|
vs[3 * i] = i;
|
||||||
|
vs[3 * i + 1] = 0;
|
||||||
|
vs[3 * i + 2] = 1;
|
||||||
|
}
|
||||||
|
Drawing drawLineStrip = new Drawing(vs, Stamp.V, GL.GL_LINE_STRIP);
|
||||||
|
|
||||||
|
////create drawLineStripWithNormal
|
||||||
|
//the content of vs is Nx,Ny,Nz,Vx,Vy,Vz, Nx,Ny,Nz,Vx,Vy,Vz, ...
|
||||||
|
vs = new double[n * 6];
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
//nx,ny,nz
|
||||||
|
vs[6 * i] = 1;
|
||||||
|
vs[6 * i + 1] = 0;
|
||||||
|
vs[6 * i + 2] = 0;
|
||||||
|
//x,y,z
|
||||||
|
vs[6 * i + 3] = i;
|
||||||
|
vs[6 * i + 4] = 0;
|
||||||
|
vs[6 * i + 5] = 2;
|
||||||
|
}
|
||||||
|
//V means Vertex; N means Normal
|
||||||
|
Drawing drawLineStripWithNormal =
|
||||||
|
new Drawing(vs, Stamp.NV, GL.GL_LINE_STRIP);
|
||||||
|
|
||||||
|
////create drawColorLines
|
||||||
|
vs = new double[n * 6];
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
//the rgb values set casually.
|
||||||
|
//r,g,b
|
||||||
|
vs[6 * i] = i % 3 / 2D;
|
||||||
|
vs[6 * i + 1] = i % 5 / 4D;
|
||||||
|
vs[6 * i + 2] = i % 7 / 6D;
|
||||||
|
//x,y,z
|
||||||
|
vs[6 * i + 3] = i;
|
||||||
|
vs[6 * i + 4] = 0;
|
||||||
|
vs[6 * i + 5] = 3;
|
||||||
|
}
|
||||||
|
//V means Vertex; C means Color
|
||||||
|
Drawing drawLineStripWithColor = new Drawing(vs, Stamp.CV, GL.GL_LINE_STRIP);
|
||||||
|
|
||||||
|
DemoUtil.Present("DrawLines",
|
||||||
|
new DispList(drawPoints, drawLineStrip
|
||||||
|
, drawLineStripWithNormal, drawLineStripWithColor));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates drawing triangles using OpenGL primitives.
|
||||||
|
/// Shows how to create colored triangles (CV) and colored triangles with normals (CNV).
|
||||||
|
/// Illustrates packing of vertex attributes (color, normal, position) into arrays for rendering.
|
||||||
|
/// </summary>
|
||||||
|
public static void DrawTrianglesByPrimitives()
|
||||||
|
{
|
||||||
|
int n = 10;// triangle num
|
||||||
|
double[] vs;
|
||||||
|
|
||||||
|
////create drawTrisCV
|
||||||
|
//each triangle has 3 point; each point has r,g,b,x,y,z, totally 6 doubles.
|
||||||
|
vs = new double[n * 3 * 6];
|
||||||
|
for (int i = 0, k = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
//the rgb values set as casual.
|
||||||
|
vec3d_t rgb = ColorUtil.GetDiscreteRgb(i);
|
||||||
|
tri3d_t tri = new tri3d_t(new vec3d_t(i, 0, 0), new vec3d_t(i + 1, 0, 0), new vec3d_t(i + 0.5, 0, 1));
|
||||||
|
for (int j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
vs[k++] = rgb.x;
|
||||||
|
vs[k++] = rgb.y;
|
||||||
|
vs[k++] = rgb.z;
|
||||||
|
vs[k++] = tri[j].x;
|
||||||
|
vs[k++] = tri[j].y;
|
||||||
|
vs[k++] = tri[j].z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//V means Vertex; C means Color
|
||||||
|
Drawing drawTrisCV = new Drawing(vs, Stamp.CV, GL.GL_TRIANGLES);
|
||||||
|
|
||||||
|
////create drawTrisCNV
|
||||||
|
/////each triangle has 3 point; each point has r,g,b,nx,ny,nz,x,y,z, totally 6 doubles.
|
||||||
|
vs = new double[n * 3 * 9];
|
||||||
|
for (int i = 0, k = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
//the rgb values set as casual.
|
||||||
|
vec3d_t rgb = ColorUtil.GetDiscreteRgb(i);
|
||||||
|
tri3d_t tri = new tri3d_t(new vec3d_t(i, 0, 3), new vec3d_t(i + 1, 0, 3), new vec3d_t(i + 0.5, 0, 4));
|
||||||
|
vec3d_t nn = tri.GetNormal();
|
||||||
|
for (int j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
vs[k++] = rgb.x;
|
||||||
|
vs[k++] = rgb.y;
|
||||||
|
vs[k++] = rgb.z;
|
||||||
|
vs[k++] = nn.x;
|
||||||
|
vs[k++] = nn.y;
|
||||||
|
vs[k++] = nn.z;
|
||||||
|
vs[k++] = tri[j].x;
|
||||||
|
vs[k++] = tri[j].y;
|
||||||
|
vs[k++] = tri[j].z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//V means Vertex; C means Color; N means Normal
|
||||||
|
Drawing drawTrisCNV = new Drawing(vs, Stamp.CNV, GL.GL_TRIANGLES);
|
||||||
|
|
||||||
|
//the color of colorTrisDraw is not influence by outer color setting.
|
||||||
|
DemoUtil.Present("DrawTrianglesByPrimitives",
|
||||||
|
new DispList(new RgbTreat(1, 0, 0), drawTrisCV, drawTrisCNV));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates drawing 3D triangles using the tri3d_t helper class.
|
||||||
|
/// Creates a series of triangles and renders them as both face (filled) and line (wireframe) drawings.
|
||||||
|
/// Shows how to apply different colors to faces and lines of the same geometry.
|
||||||
|
/// </summary>
|
||||||
|
public static void DrawTri3d()
|
||||||
|
{
|
||||||
|
int n = 10;
|
||||||
|
List<tri3d_t> tris = new List<tri3d_t>(n);
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
tris.Add(new tri3d_t(new vec3d_t(i, 0, 0), new vec3d_t(i + 1, 0, 0), new vec3d_t(i + 0.5, 0, 1)));
|
||||||
|
|
||||||
|
Drawing faceDraw = tris.GetFaceDrawing();
|
||||||
|
Drawing linesDraw = tris.ToLineDrawing();
|
||||||
|
|
||||||
|
DemoUtil.Present("DrawTri3d",
|
||||||
|
new DispList(new RgbTreat(0, 0, 1), linesDraw
|
||||||
|
, new RgbTreat(1, 0, 0), faceDraw));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
//FreeDrawing();
|
||||||
|
//DrawLines();
|
||||||
|
//DrawTrianglesByPrimitives();
|
||||||
|
DrawTri3d();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using Hi.Geom;
|
||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Native;
|
||||||
|
|
||||||
|
namespace Sample.Disp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates basic object picking with mouse interaction in the HiAPI system.
|
||||||
|
/// Shows how to create a pickable 3D object that responds to mouse events by changing its appearance.
|
||||||
|
/// Implements the Pickable base class to enable mouse event handling.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoPick1.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public class DemoPick1 : Pickable, IDisplayee
|
||||||
|
{
|
||||||
|
bool isMouseOver = false;
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
bind.PickID = PickingID;
|
||||||
|
bind.Rgb = new vec3d_t(isMouseOver ? 0 : 1, 1, 1);
|
||||||
|
new box3d_t(0, 0, 0, 1, 1, 1).DisplayFace(bind);
|
||||||
|
bind.PickID = 0;
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(ref box3d_t dst)
|
||||||
|
{
|
||||||
|
dst = dst.Expanded(new vec3d_t(0, 0, 0));
|
||||||
|
dst = dst.Expanded(new vec3d_t(1, 1, 1));
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void OnMouseEnter(ui_event_type e, DispEngine dispEngine)
|
||||||
|
{
|
||||||
|
isMouseOver = true;
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void OnMouseLeave(ui_event_type e, DispEngine dispEngine)
|
||||||
|
{
|
||||||
|
isMouseOver = false;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Entry point for the DemoPick1 example.
|
||||||
|
/// Creates and displays a simple pickable object that changes color on mouse hover.
|
||||||
|
/// </summary>
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
DemoUtil.Present("DemoPick1", new DemoPick1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
using Hi.Geom;
|
||||||
|
using Hi.Disp;
|
||||||
|
using System;
|
||||||
|
using Hi.Coloring;
|
||||||
|
|
||||||
|
namespace Sample.Disp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates advanced object picking with multiple pickable objects.
|
||||||
|
/// Shows how to create and manage multiple pickable objects with different visual appearances.
|
||||||
|
/// Implements proper resource cleanup through the IDisposable interface.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoPick2.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public class DemoPick2 : IDisplayee, IDisposable
|
||||||
|
{
|
||||||
|
readonly Pickable pickableA = new ShowEventPickable { Tag = "A" };
|
||||||
|
readonly Pickable pickableB = new ShowEventPickable { Tag = "B" };
|
||||||
|
readonly Pickable pickableC = new ShowEventPickable { Tag = "C" };
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
bind.PickID = pickableA.PickingID;
|
||||||
|
bind.Rgb = ColorUtil.GetDiscreteRgb(1);
|
||||||
|
new box3d_t(0, 0, 0, 1, 1, 1).DisplayFace(bind);
|
||||||
|
|
||||||
|
bind.PickID = pickableB.PickingID;
|
||||||
|
bind.Rgb = ColorUtil.GetDiscreteRgb(2);
|
||||||
|
new box3d_t(0, 0, 1, 1, 1, 2).DisplayFace(bind);
|
||||||
|
|
||||||
|
bind.PickID = pickableC.PickingID;
|
||||||
|
bind.Rgb = ColorUtil.GetDiscreteRgb(3);
|
||||||
|
new box3d_t(0, 0, 2, 1, 1, 3).DisplayFace(bind);
|
||||||
|
|
||||||
|
bind.PickID = 0;
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(ref box3d_t dst)
|
||||||
|
{
|
||||||
|
dst = dst.Expanded(new vec3d_t(0, 0, 0));
|
||||||
|
dst = dst.Expanded(new vec3d_t(1, 1, 3));
|
||||||
|
}
|
||||||
|
#region IDisposable Support
|
||||||
|
private bool disposedValue = false; // To detect redundant calls
|
||||||
|
/// <inheritdoc/>
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
pickableA.Dispose();
|
||||||
|
pickableB.Dispose();
|
||||||
|
pickableC.Dispose();
|
||||||
|
}
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entry point for the DemoPick2 example.
|
||||||
|
/// Creates and displays multiple pickable objects with distinct colors and positions.
|
||||||
|
/// Demonstrates separation of picking behavior from visual representation.
|
||||||
|
/// </summary>
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
DemoUtil.Present("DemoPick2", new DemoPick2());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Geom;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Sample.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates creation of pickable 3D geometry at the primitive level.
|
||||||
|
/// Shows how to assign picking IDs directly to geometry vertices and create interactive triangles.
|
||||||
|
/// Uses a lower-level approach than the Pickable base class for more precise control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoPickable.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public class DemoPickable : IDisplayee
|
||||||
|
{
|
||||||
|
private readonly Drawing draw;
|
||||||
|
private readonly ShowEventPickable pickable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of DemoPickable.
|
||||||
|
/// Creates a pickable triangle with a specific picking ID for user interaction.
|
||||||
|
/// </summary>
|
||||||
|
public DemoPickable()
|
||||||
|
{
|
||||||
|
pickable = new ShowEventPickable();
|
||||||
|
double pid = pickable.PickingID;
|
||||||
|
double[] vs = new double[] {
|
||||||
|
//pickID, x,y,z
|
||||||
|
pid, 0,0.1,0.1,
|
||||||
|
pid, 0.1,0,0,
|
||||||
|
pid, 0.1,0,0.1
|
||||||
|
};
|
||||||
|
draw = new Drawing(vs, Stamp.PV, GL.GL_TRIANGLES);
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
draw.Display(bind);
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(ref box3d_t dst)
|
||||||
|
{
|
||||||
|
draw.ExpandToBox3d(ref dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entry point for the DemoPickable example.
|
||||||
|
/// Creates and displays a pickable triangle that can respond to mouse events.
|
||||||
|
/// Demonstrates integration of picking functionality with geometric primitives.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
DemoUtil.Present("DemoPickable", new DemoPickable());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using Hi.Geom;
|
||||||
|
using Hi.Disp;
|
||||||
|
|
||||||
|
namespace Sample.Disp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates a simple solar system animation using <see cref="IDisplayee"/> interface.
|
||||||
|
/// Shows how to create a hierarchical transform structure with sun, earth and moon using
|
||||||
|
/// <see cref="mat4d_t"/> matrices and model matrix stack transformations.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoSatellite.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public class DemoSatellite : IDisplayee
|
||||||
|
{
|
||||||
|
Drawing sun;
|
||||||
|
Drawing earth;
|
||||||
|
Drawing moon;
|
||||||
|
double angle_earth;
|
||||||
|
double angle_moon;
|
||||||
|
DemoSatellite()
|
||||||
|
{
|
||||||
|
sun = box3d_t.CenterUnitBox.ScaledFromCenter(4).ToDraw_Face();
|
||||||
|
earth = box3d_t.CenterUnitBox.ScaledFromCenter(2).ToDraw_Face();
|
||||||
|
moon = box3d_t.CenterUnitBox.ToDraw_Face();
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
sun.Display(bind);
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Mul(new mat4d_t(new AxisAngle4d(new vec3d_t(0, 0, 1), angle_earth += 0.03)));
|
||||||
|
bind.ModelMatStack.Mul(new mat4d_t(new vec3d_t(12, 0, 0)));
|
||||||
|
earth.Display(bind);
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Mul(new mat4d_t(new AxisAngle4d(new vec3d_t(0, 0, 1), angle_moon += 0.02)));
|
||||||
|
bind.ModelMatStack.Mul(new mat4d_t(new vec3d_t(4, 0, 0)));
|
||||||
|
moon.Display(bind);
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(ref box3d_t dst)
|
||||||
|
{
|
||||||
|
dst = dst.Expanded(new vec3d_t(-14, -14, -2));
|
||||||
|
dst = dst.Expanded(new vec3d_t(14, 14, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
DemoUtil.Present("DemoSatellite", new DemoSatellite());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Geom;
|
||||||
|
using Hi.HiNcKits;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Sample.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs a display sample to the point where its <see cref="IDisplayee"/> is ready to be rendered.
|
||||||
|
/// HiAPI ships no rendering canvas, so the samples in this project stop at the handover: they
|
||||||
|
/// compose the displayee and report it, and the application hands that same object to a canvas of
|
||||||
|
/// its own. See the Building Your Own Rendering Canvas guide for the canvas side.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ### Source Code
|
||||||
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoUtil.cs)]
|
||||||
|
/// </remarks>
|
||||||
|
public static class DemoUtil
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the application, reports the displayee's extent, and shuts down again —
|
||||||
|
/// the headless equivalent of opening a window on it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">A name for the sample, used in the console output.</param>
|
||||||
|
/// <param name="displayee">The object a rendering canvas would display.</param>
|
||||||
|
public static void Present(string title, IDisplayee displayee)
|
||||||
|
{
|
||||||
|
if (displayee is null) throw new ArgumentNullException(nameof(displayee));
|
||||||
|
|
||||||
|
using var loggerFactory = LoggerFactory.Create(b => b.AddConsole());
|
||||||
|
LocalApp.AppBegin(loggerFactory.CreateLogger("Hi.Sample"));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
box3d_t box = new box3d_t();
|
||||||
|
displayee.ExpandToBox3d(ref box);
|
||||||
|
Console.WriteLine($"{title}: {displayee.GetType().Name} bounding {box}");
|
||||||
|
Console.WriteLine("Assign it to your canvas' DispEngine.Displayee to see it.");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
LocalApp.AppEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
using Hi.Disp.Flag;
|
||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Machining.MachiningEquipmentUtils;
|
||||||
|
using Hi.Mech.Topo;
|
||||||
|
using Hi.Numerical;
|
||||||
|
using Hi.Numerical.NcArgs;
|
||||||
|
using System.Collections;
|
||||||
|
using System;
|
||||||
|
using Hi.Geom;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Sample.Disp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Displayee for Heidenhain coordinate entry visualization.
|
||||||
|
/// </summary>
|
||||||
|
public class HeidenhainCoordinateEntryDisplayee : IAnchoredDisplayee
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether to show Heidenhain datum preset information.
|
||||||
|
/// </summary>
|
||||||
|
public bool ShowHeidenhainDatumPreset { get; set; } = true;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether to show Heidenhain datum shift information.
|
||||||
|
/// </summary>
|
||||||
|
public bool ShowHeidenhainDatumShift { get; set; } = true;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the function that provides the NcEnv instance.
|
||||||
|
/// </summary>
|
||||||
|
public Func<HardNcEnv> NcEnvFunc { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the function that provides the machining equipment.
|
||||||
|
/// </summary>
|
||||||
|
public Func<IMachiningEquipment> MillingEquipmentFunc { get; set; }
|
||||||
|
HardNcEnv NcEnv => NcEnvFunc?.Invoke();
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Heidenhain Cycle Def 247 Q339 value.
|
||||||
|
/// </summary>
|
||||||
|
public int HeidenhainCycleDef247Q339 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Heidenhain Cycle Def 7 arguments.
|
||||||
|
/// </summary>
|
||||||
|
public HeidenhainCycleDef7Arg HeidenhainCycleDef7Arg { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ncEnvFunc">The function that provides the NcEnv instance.</param>
|
||||||
|
/// <param name="millingEquipmentSource">The function that provides the machining equipment.</param>
|
||||||
|
public HeidenhainCoordinateEntryDisplayee(Func<HardNcEnv> ncEnvFunc, Func<IMachiningEquipment> millingEquipmentSource)
|
||||||
|
{
|
||||||
|
NcEnvFunc = ncEnvFunc;
|
||||||
|
MillingEquipmentFunc = millingEquipmentSource;
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
HardNcEnv ncEnv = NcEnv;
|
||||||
|
if (ncEnv == null || NcEnv.CncBrand != CncBrand.Heidenhain)
|
||||||
|
return;
|
||||||
|
|
||||||
|
////Console.WriteLine($"B: {CoordinateIndex}; {coordinateMove}");
|
||||||
|
IMachiningEquipment equipment = MillingEquipmentFunc?.Invoke();
|
||||||
|
if (equipment == null
|
||||||
|
|| !equipment.TryGetMachinePositionAtTableMountZero(out vec3d_t mcXyz_AttacherAtTableMountZero))
|
||||||
|
return;
|
||||||
|
|
||||||
|
vec3d_t coordinateMove;
|
||||||
|
string text;
|
||||||
|
if (HeidenhainCycleDef247Q339 == 0 && HeidenhainCycleDef7Arg == null)
|
||||||
|
return;
|
||||||
|
coordinateMove = NcFlagUtil.GetHeidenhainCoordinateOffset(
|
||||||
|
HeidenhainCycleDef247Q339, HeidenhainCycleDef7Arg, ncEnv);
|
||||||
|
//Console.WriteLine($"HeidenhainCycleDef7Arg: {HeidenhainCycleDef7Arg==null}");
|
||||||
|
string datumPresetText = null;
|
||||||
|
if (HeidenhainCycleDef247Q339 != 0 && ShowHeidenhainDatumPreset)
|
||||||
|
datumPresetText = $"Datum Preset Q339={HeidenhainCycleDef247Q339}";
|
||||||
|
string datumShiftText = null;
|
||||||
|
if (HeidenhainCycleDef7Arg != null && ShowHeidenhainDatumShift)
|
||||||
|
datumShiftText = $"Datum Shift: {HeidenhainCycleDef7Arg?.ToString() ?? "None"}";
|
||||||
|
text = string.Join(", ",
|
||||||
|
(new string[] { datumPresetText, datumShiftText }).
|
||||||
|
Where(v => v != null));
|
||||||
|
//text = $"Datum Preset Q339={HeidenhainCycleDef247Q339}, Datum Shift: #1";
|
||||||
|
//Console.WriteLine($"text: [{text}]");
|
||||||
|
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(coordinateMove - mcXyz_AttacherAtTableMountZero);
|
||||||
|
CoordinateDrawing.Display(bind, text);
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(ref box3d_t dst)
|
||||||
|
{
|
||||||
|
HardNcEnv ncEnv = NcEnv;
|
||||||
|
if (ncEnv == null || NcEnv.CncBrand != CncBrand.Heidenhain)
|
||||||
|
return;
|
||||||
|
|
||||||
|
IMachiningEquipment equipment = MillingEquipmentFunc?.Invoke();
|
||||||
|
if (equipment == null
|
||||||
|
|| !equipment.TryGetMachinePositionAtTableMountZero(out vec3d_t mcXyz_AttacherAtTableMountZero))
|
||||||
|
return;
|
||||||
|
vec3d_t coordinateMove;
|
||||||
|
if (HeidenhainCycleDef247Q339 == 0 && HeidenhainCycleDef7Arg == null)
|
||||||
|
return;
|
||||||
|
coordinateMove = NcFlagUtil.GetHeidenhainCoordinateOffset(
|
||||||
|
HeidenhainCycleDef247Q339, HeidenhainCycleDef7Arg, ncEnv);
|
||||||
|
|
||||||
|
|
||||||
|
dst = dst.Expanded(-mcXyz_AttacherAtTableMountZero + coordinateMove);
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Anchor GetAnchor()
|
||||||
|
{
|
||||||
|
return MillingEquipmentFunc?.Invoke()?.GetMachiningChain()
|
||||||
|
?.GetTableMount()?.GetAnchor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Disp.Flag;
|
||||||
|
using Hi.Geom;
|
||||||
|
using Hi.Machining.MachiningEquipmentUtils;
|
||||||
|
using Hi.Mech.Topo;
|
||||||
|
using Hi.Numerical;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Sample.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displayee for ISO coordinate entry visualization.
|
||||||
|
/// </summary>
|
||||||
|
public class IsoCoordinateEntryDisplayee : IAnchoredDisplayee
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ISO coordinate key (e.g. "G54", "G59.2").
|
||||||
|
/// </summary>
|
||||||
|
public string IsoCoordinateId { get; set; } = "G54";
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the function that provides the NcEnv instance.
|
||||||
|
/// </summary>
|
||||||
|
public Func<HardNcEnv> NcEnvFunc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the function that provides the machining equipment.
|
||||||
|
/// </summary>
|
||||||
|
public Func<IMachiningEquipment> MillingEquipmentFunc { get; set; }
|
||||||
|
HardNcEnv NcEnv => NcEnvFunc?.Invoke();
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="IsoCoordinateEntryDisplayee"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ncEnvFunc">The function that provides the NcEnv instance.</param>
|
||||||
|
/// <param name="millingEquipmentSource">The function that provides the machining equipment.</param>
|
||||||
|
public IsoCoordinateEntryDisplayee(Func<HardNcEnv> ncEnvFunc,
|
||||||
|
Func<IMachiningEquipment> millingEquipmentSource)
|
||||||
|
{
|
||||||
|
NcEnvFunc = ncEnvFunc;
|
||||||
|
MillingEquipmentFunc = millingEquipmentSource;
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
HardNcEnv ncEnv = NcEnv;
|
||||||
|
if (ncEnv == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ncEnv.IsoCoordinateTable?.TryGetValue(IsoCoordinateId, out vec3d_t coordinateMove) != true)
|
||||||
|
return;
|
||||||
|
string text = IsoCoordinateId ?? "";
|
||||||
|
|
||||||
|
IMachiningEquipment equipment = MillingEquipmentFunc?.Invoke();
|
||||||
|
if (equipment == null || !equipment.TryGetIsoCoordinatePosition(coordinateMove, out vec3d_t attacherPos))
|
||||||
|
return;
|
||||||
|
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(attacherPos);
|
||||||
|
CoordinateDrawing.Display(bind, text);
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(ref box3d_t dst)
|
||||||
|
{
|
||||||
|
HardNcEnv ncEnv = NcEnv;
|
||||||
|
if (ncEnv == null)
|
||||||
|
return;
|
||||||
|
if (ncEnv.IsoCoordinateTable?.TryGetValue(IsoCoordinateId, out vec3d_t coordinateMove) != true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
IMachiningEquipment equipment = MillingEquipmentFunc?.Invoke();
|
||||||
|
if (equipment == null || !equipment.TryGetIsoCoordinatePosition(coordinateMove, out vec3d_t attacherPos))
|
||||||
|
return;
|
||||||
|
dst = dst.Expanded(attacherPos);
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
/// <returns>Table Mount if existed; otherwise, return null.</returns>
|
||||||
|
public Anchor GetAnchor()
|
||||||
|
{
|
||||||
|
return MillingEquipmentFunc?.Invoke()?.GetMachiningChain()?.GetAnchor();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,250 @@
|
|||||||
|
using Hi.Coloring;
|
||||||
|
using Hi.MachiningProcs;
|
||||||
|
using Hi.Common;
|
||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Disp.Flag;
|
||||||
|
using Hi.Mech.Topo;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections;
|
||||||
|
using Hi.Geom;
|
||||||
|
using System.Linq;
|
||||||
|
using Hi.NcMech.Solids;
|
||||||
|
using Hi.Numerical;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Sample.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a displayable wrapper for a machining project.
|
||||||
|
/// </summary>
|
||||||
|
public class MachiningProjectDisplayee : IDisplayee, IGetAnchor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current milling course from the host function.
|
||||||
|
/// </summary>
|
||||||
|
public MachiningProject MachiningProject => LocalProjectService.MachiningProject;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the function that provides the machining project.
|
||||||
|
/// </summary>
|
||||||
|
public LocalProjectService LocalProjectService { get; set; }
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// Initializes a new instance of the <see cref="MachiningProjectDisplayee"/> class.
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="machiningProject">The machining project to display.</param>
|
||||||
|
///// <param name="renderingFlagBitArray">The bit array controlling rendering flags.</param>
|
||||||
|
//public MachiningProjectDisplayee(MachiningProject machiningProject,
|
||||||
|
// BitArray renderingFlagBitArray)
|
||||||
|
// {
|
||||||
|
// RenderingFlagBitArray = renderingFlagBitArray;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="MachiningProjectDisplayee"/> class with default rendering flags.
|
||||||
|
/// </summary>
|
||||||
|
public MachiningProjectDisplayee(LocalProjectService localProjectService)
|
||||||
|
{ LocalProjectService = localProjectService; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the bit array that controls which elements are rendered.
|
||||||
|
/// </summary>
|
||||||
|
public BitArray RenderingFlagBitArray { get; set; } = new BitArray(EnumUtil.GetEnumBitArrayCap<RenderingFlag>())
|
||||||
|
{
|
||||||
|
[(int)RenderingFlag.DimensionBar] = true,
|
||||||
|
[(int)RenderingFlag.WorkpieceGeom] = true,
|
||||||
|
[(int)RenderingFlag.Fixture] = true,
|
||||||
|
[(int)RenderingFlag.ClStrip] = true,
|
||||||
|
//[(int)RenderingFlag.Mech] = true,
|
||||||
|
};
|
||||||
|
IsoCoordinateEntryDisplayee isoCoordinateEntryDisplayee;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the ISO coordinate entry displayee for ISO-based coordinate systems.
|
||||||
|
/// </summary>
|
||||||
|
public IsoCoordinateEntryDisplayee IsoCoordinateEntryDisplayee =>
|
||||||
|
isoCoordinateEntryDisplayee ??= new IsoCoordinateEntryDisplayee(
|
||||||
|
() => MachiningProject.NcEnv,
|
||||||
|
() => LocalProjectService.MachiningEquipment);
|
||||||
|
HeidenhainCoordinateEntryDisplayee heidenhainCoordinateEntryDisplayee;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Heidenhain coordinate entry displayee for Heidenhain-based coordinate systems.
|
||||||
|
/// </summary>
|
||||||
|
public HeidenhainCoordinateEntryDisplayee HeidenhainCoordinateEntryDisplayee =>
|
||||||
|
heidenhainCoordinateEntryDisplayee ??= new HeidenhainCoordinateEntryDisplayee(
|
||||||
|
() => MachiningProject.NcEnv,
|
||||||
|
() => LocalProjectService.MachiningEquipment);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of anchored displayees based on current rendering flags.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A list of anchored displayees for rendering</returns>
|
||||||
|
List<IAnchoredDisplayee> GetAnchoredDisplayeeList()
|
||||||
|
{
|
||||||
|
List<IAnchoredDisplayee> dst = new List<IAnchoredDisplayee>();
|
||||||
|
MachiningProject machiningProject = MachiningProject;
|
||||||
|
if (machiningProject == null)
|
||||||
|
return dst;
|
||||||
|
|
||||||
|
LocalProjectService localProjectService = LocalProjectService;
|
||||||
|
HardNcEnv ncEnv = machiningProject.NcEnv;
|
||||||
|
//the execution scene draws the RUNTIME face throughout (equipment
|
||||||
|
//split: the service facades expose the authored setup face instead)
|
||||||
|
var machiningEquipment = localProjectService.MachiningEquipment;
|
||||||
|
var workpiece = machiningEquipment?.Workpiece;
|
||||||
|
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.ClStrip])
|
||||||
|
{
|
||||||
|
localProjectService.ClStrip.IsKeepingDispAlive = true;
|
||||||
|
dst.Add(new AnchoredDisplayee(
|
||||||
|
workpiece?.ProgramZeroAnchor,
|
||||||
|
localProjectService.ClStrip));
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.Mech])
|
||||||
|
{
|
||||||
|
if (machiningEquipment != null)
|
||||||
|
{
|
||||||
|
List<IAnchoredDisplayee> machAncDisplayees =
|
||||||
|
machiningEquipment.GetAnchoredDisplayeeList() ?? [];
|
||||||
|
HashSet<Anchor> exclusiveAnchorSet = new([
|
||||||
|
.. workpiece?.Asmb.DescendantAnchors()??[],
|
||||||
|
.. machiningEquipment.MachiningTool?.GetAsmb().DescendantAnchors()??[],
|
||||||
|
.. machiningEquipment.Fixture?.Asmb.DescendantAnchors()??[],
|
||||||
|
]);
|
||||||
|
dst.AddRange(machAncDisplayees.Where(ad =>
|
||||||
|
!exclusiveAnchorSet.Contains(ad.GetAnchor())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom])
|
||||||
|
{
|
||||||
|
if (workpiece != null)
|
||||||
|
dst.AddRange(localProjectService.WorkpieceService
|
||||||
|
.GetAnchoredDisplayeeList());
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.Tool])
|
||||||
|
{
|
||||||
|
if (machiningEquipment?.MachiningTool != null)
|
||||||
|
dst.Add(new AnchoredDisplayee(
|
||||||
|
machiningEquipment.MachiningTool?.GetAnchor(),
|
||||||
|
machiningEquipment.MachiningTool));
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.Fixture])
|
||||||
|
{
|
||||||
|
if (machiningEquipment?.Fixture != null)
|
||||||
|
dst.Add(new AnchoredDisplayee(
|
||||||
|
machiningEquipment.Fixture.GetAnchor(),
|
||||||
|
machiningEquipment.Fixture));
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.ProgramZero])
|
||||||
|
{
|
||||||
|
if (workpiece != null)
|
||||||
|
dst.Add(workpiece.ProgramZeroAnchor);
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.IsoCoordinate])
|
||||||
|
{
|
||||||
|
dst.Add(IsoCoordinateEntryDisplayee);
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.HeidenhainCoordinate]
|
||||||
|
&& ncEnv.CncBrand == CncBrand.Heidenhain)
|
||||||
|
{
|
||||||
|
dst.Add(HeidenhainCoordinateEntryDisplayee);
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the root anchor for the display hierarchy based on current rendering flags.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The root anchor to use for rendering</returns>
|
||||||
|
internal static Anchor GetRootAnchor(
|
||||||
|
LocalProjectService localProjectService, BitArray renderingFlagBitArray)
|
||||||
|
{
|
||||||
|
//runtime face throughout: this roots the execution scene
|
||||||
|
var machiningEquipment = localProjectService?.MachiningEquipment;
|
||||||
|
if (renderingFlagBitArray[(int)RenderingFlag.Mech])
|
||||||
|
return machiningEquipment?.GetAnchor();
|
||||||
|
else if (renderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom])
|
||||||
|
return machiningEquipment?.Workpiece?.GetAnchor();
|
||||||
|
else if (renderingFlagBitArray[(int)RenderingFlag.Fixture])
|
||||||
|
return machiningEquipment?.Fixture?.GetAnchor();
|
||||||
|
else if (renderingFlagBitArray[(int)RenderingFlag.Tool])
|
||||||
|
return machiningEquipment?.MachiningTool?.GetAnchor();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Anchor GetAnchor() => GetRootAnchor(LocalProjectService, RenderingFlagBitArray);
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Display(Bind bind)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"RB: {string.Join(',', Enumerable.Range(0,
|
||||||
|
// RenderingFlagBitArray.Length).Select(RenderingFlagBitArray.Get))}");
|
||||||
|
|
||||||
|
//ClStrip pos has to be update by ClStrip.
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom]
|
||||||
|
&& !RenderingFlagBitArray[(int)RenderingFlag.ClStrip]
|
||||||
|
&& LocalProjectService?.ClStrip.CallRefreshDrawing == true)
|
||||||
|
LocalProjectService?.ClStrip.RefreshDrawingInRendering(false);
|
||||||
|
|
||||||
|
bind.PushCoveringPixelMode();
|
||||||
|
double offsetHOnCover = 0;
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.DimensionBar])
|
||||||
|
{
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(0, offsetHOnCover, 0);
|
||||||
|
DimensionBar.Display(bind, "mm");
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
offsetHOnCover += DimensionBar.OffsetH;
|
||||||
|
}
|
||||||
|
if (RenderingFlagBitArray[(int)RenderingFlag.ColorScaleBar]
|
||||||
|
&& MachiningProject?.MillingGuide?.DictionaryColorGuide?.SelectedColorGuide
|
||||||
|
is IGetRangeColorRule getRangeColorRule)
|
||||||
|
{
|
||||||
|
var rangeColorRule = getRangeColorRule.GetRangeColorRule();
|
||||||
|
if (rangeColorRule != null)
|
||||||
|
{
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(0, offsetHOnCover, 0);
|
||||||
|
|
||||||
|
ColorScaleBar.Display(bind,
|
||||||
|
rangeColorRule.Floor, rangeColorRule.Ceiling,
|
||||||
|
rangeColorRule.GetRgb, "L.", "");
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
offsetHOnCover += ColorScaleBar.OffsetH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (LocalProjectService?.WorkpieceService?.HasDiffOverlay == true)
|
||||||
|
{
|
||||||
|
bind.ModelMatStack.Push();
|
||||||
|
bind.ModelMatStack.Trans(0, offsetHOnCover, 0);
|
||||||
|
|
||||||
|
var rangeColorRule = LocalProjectService.WorkpieceService.DiffRangeColorRule;
|
||||||
|
ColorScaleBar.Display(bind,
|
||||||
|
rangeColorRule.Floor, rangeColorRule.Ceiling,
|
||||||
|
rangeColorRule.GetRgb, "Df.", "");
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
offsetHOnCover += ColorScaleBar.OffsetH;
|
||||||
|
}
|
||||||
|
bind.ModelMatStack.Pop();
|
||||||
|
|
||||||
|
bind.PushColorByRgb(1, 1, 1);
|
||||||
|
var machiningEquipment = LocalProjectService?.MachiningEquipment;
|
||||||
|
//Collision red is per-scenario state owned by the execution equipment
|
||||||
|
//(never stored on the shared Solid geometry): scope it to this scene
|
||||||
|
//so the setup topology never paints it.
|
||||||
|
using (CollisionRedScope.Enter(
|
||||||
|
machiningEquipment == null ? null : machiningEquipment.IsCollisionRed))
|
||||||
|
{
|
||||||
|
machiningEquipment?.GetAsmb()?.Display(bind,
|
||||||
|
GetAnchor(),
|
||||||
|
GetAnchoredDisplayeeList().ToArray());
|
||||||
|
}
|
||||||
|
bind.PopColor();
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void ExpandToBox3d(ref box3d_t dst)
|
||||||
|
{
|
||||||
|
//Console.WriteLine($"dst.A: {dst}");
|
||||||
|
LocalProjectService?.MachiningEquipment?.GetAsmb()?.ExpandToBox3d(ref dst,
|
||||||
|
GetAnchor(),
|
||||||
|
GetAnchoredDisplayeeList().ToArray());
|
||||||
|
//Console.WriteLine($"dst.B: {dst}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,8 +30,8 @@ public static class DemoBuildGeom
|
|||||||
TransformationGeom transformationGeom = new TransformationGeom()
|
TransformationGeom transformationGeom = new TransformationGeom()
|
||||||
{
|
{
|
||||||
Transformer = new GeneralTransform(1,
|
Transformer = new GeneralTransform(1,
|
||||||
new StaticRotation(new Vec3d(0, 0, 1), MathUtil.ToRad(15), new Vec3d(0, 0, 0)),
|
new StaticRotation(new vec3d_t(0, 0, 1), MathUtil.ToRad(15), new vec3d_t(0, 0, 0)),
|
||||||
new StaticTranslation(new Vec3d(0, 0, 0))),
|
new StaticTranslation(new vec3d_t(0, 0, 0))),
|
||||||
Geom = stl
|
Geom = stl
|
||||||
};
|
};
|
||||||
GeomCombination geomCombination = new GeomCombination(stlFile, transformationGeom);
|
GeomCombination geomCombination = new GeomCombination(stlFile, transformationGeom);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Sample.Geom;
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Demonstrates how to create and calculate bounding boxes for different geometric objects.
|
/// Demonstrates how to create and calculate bounding boxes for different geometric objects.
|
||||||
/// Shows the use of Box3d to encompass multiple geometric elements with a single boundary.
|
/// Shows the use of box3d_t to encompass multiple geometric elements with a single boundary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// ### Source Code
|
/// ### Source Code
|
||||||
@@ -16,11 +16,11 @@ public static class DemoIExpandToBox3d
|
|||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
#region DocSite.CountBoundingBox
|
#region DocSite.CountBoundingBox
|
||||||
Box3d objA = new Box3d(0, 0, 0, 1, 1, 1);
|
box3d_t objA = new box3d_t(0, 0, 0, 1, 1, 1);
|
||||||
Box3d objB = new Box3d(-1, -2, -3, 3, 2, 1);
|
box3d_t objB = new box3d_t(-1, -2, -3, 3, 2, 1);
|
||||||
Vec3d objC = new Vec3d(-2, 3, -5);
|
vec3d_t objC = new vec3d_t(-2, 3, -5);
|
||||||
|
|
||||||
Box3d boundingbox = new Box3d(objA, objB, objC);
|
box3d_t boundingbox = new box3d_t(objA, objB, objC);
|
||||||
Console.WriteLine("boundingbox: " + boundingbox);
|
Console.WriteLine("boundingbox: " + boundingbox);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -11,7 +11,7 @@
|
|||||||
</Description>
|
</Description>
|
||||||
<Configurations>Debug;Release</Configurations>
|
<Configurations>Debug;Release</Configurations>
|
||||||
<VersionBuild>0</VersionBuild>
|
<VersionBuild>0</VersionBuild>
|
||||||
<VersionPrefix>3.1.$(VersionBuild)</VersionPrefix>
|
<VersionPrefix>3.2.$(VersionBuild)</VersionPrefix>
|
||||||
<Product>$(AssemblyName)</Product>
|
<Product>$(AssemblyName)</Product>
|
||||||
<ApplicationIcon>techcoordinate.ico</ApplicationIcon>
|
<ApplicationIcon>techcoordinate.ico</ApplicationIcon>
|
||||||
<Copyright>Copyright 2025 Tech Coordinate Co., Ltd.</Copyright>
|
<Copyright>Copyright 2025 Tech Coordinate Co., Ltd.</Copyright>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<ProjectReference Include="..\HiNc\HiNc.csproj" />
|
<ProjectReference Include="..\HiNc\HiNc.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Condition="'$(Configuration)'=='Release'">
|
<ItemGroup Condition="'$(Configuration)'=='Release'">
|
||||||
<PackageReference Include="HiNc" Version="3.1.*" />
|
<PackageReference Include="HiNc" Version="3.2.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -21,7 +21,7 @@ namespace Sample.MachineTool
|
|||||||
/// ### Source Code
|
/// ### Source Code
|
||||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineTool.cs)]
|
/// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineTool.cs)]
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool
|
public class DemoBuildMachineTool
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers this type's deserializer with the given <see cref="XFactory"/>
|
/// Registers this type's deserializer with the given <see cref="XFactory"/>
|
||||||
@@ -37,12 +37,16 @@ namespace Sample.MachineTool
|
|||||||
/// Generates an XYZ-ABC machine tool instance from embedded resources.
|
/// Generates an XYZ-ABC machine tool instance from embedded resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A configured machine tool model.</returns>
|
/// <returns>A configured machine tool model.</returns>
|
||||||
public static CodeXyzabcMachineTool GenXyzabcMachineTool()
|
public static GeneralXyzabcMachineTool GenXyzabcMachineTool()
|
||||||
{
|
{
|
||||||
CodeXyzabcChain chain = new CodeXyzabcChain("[O][Y][X][C][w];[O][Z][B][S][t]");
|
GeneralXyzabcMachineTool dst = GeneralXyzabcMachineTool.CreateFromChainCode(
|
||||||
if (chain.ToolBuckleTransformer is StaticTranslation st)
|
"[O][Y][X][C][w];[O][Z][B][S][t]");
|
||||||
st.Trans = new Vec3d(-72.40, 72.40, 176.44);
|
if (dst.ToolMountTransformer is StaticTranslation st)
|
||||||
chain.TransformerB.Pivot = new Vec3d(-72.4, -177.4, 225.94);
|
st.Trans = new vec3d_t(-72.40, 72.40, 176.44);
|
||||||
|
//the spindle turns the tool about its own axis: the rotation's pivot
|
||||||
|
//sits on the tool mount's origin, where the offset above moved it.
|
||||||
|
dst.SpindleTransformer.Pivot = new vec3d_t(-72.40, 72.40, 176.44);
|
||||||
|
dst.TransformerB.Pivot = new vec3d_t(-72.4, -177.4, 225.94);
|
||||||
Dictionary<string, Solid> solidMap = new Dictionary<string, Solid>()
|
Dictionary<string, Solid> solidMap = new Dictionary<string, Solid>()
|
||||||
{
|
{
|
||||||
["O"] = new Solid(new Stl("MachineTool/base.stl")),
|
["O"] = new Solid(new Stl("MachineTool/base.stl")),
|
||||||
@@ -53,10 +57,8 @@ namespace Sample.MachineTool
|
|||||||
["C"] = new Solid(new Stl("MachineTool/C.stl")),
|
["C"] = new Solid(new Stl("MachineTool/C.stl")),
|
||||||
["S"] = new Solid(new Stl("MachineTool/spindle.stl")),
|
["S"] = new Solid(new Stl("MachineTool/spindle.stl")),
|
||||||
};
|
};
|
||||||
chain.AnchorToSolid.BuildAnchorToSolid(
|
dst.AnchorToSolid.BuildAnchorToSolid(
|
||||||
chain.Asmb.GetDescendantAnchors(), solidMap);
|
dst.Asmb.DescendantAnchors(), solidMap);
|
||||||
|
|
||||||
CodeXyzabcMachineTool dst = new CodeXyzabcMachineTool(chain);
|
|
||||||
dst.GenerateCollisionIndexPairs();
|
dst.GenerateCollisionIndexPairs();
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
@@ -64,7 +66,7 @@ namespace Sample.MachineTool
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The cached machine tool instance.
|
/// The cached machine tool instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CodeXyzabcMachineTool MachineTool { get; }
|
GeneralXyzabcMachineTool MachineTool { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default constructor that initializes the machine tool model.
|
/// Default constructor that initializes the machine tool model.
|
||||||
@@ -81,9 +83,15 @@ namespace Sample.MachineTool
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public XElement ToXElement() => new XElement(XName);
|
public XElement ToXElement() => new XElement(XName);
|
||||||
#endregion
|
#endregion
|
||||||
/// <inheritdoc/>
|
/// <summary>
|
||||||
public CodeXyzabcMachineTool GetXyzabcMachineTool() => MachineTool;
|
/// Gets the built machine tool.
|
||||||
/// <inheritdoc/>
|
/// </summary>
|
||||||
|
/// <returns>Machine tool.</returns>
|
||||||
|
public GeneralXyzabcMachineTool GetXyzabcMachineTool() => MachineTool;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the machine tool as a machining chain.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Machining chain.</returns>
|
||||||
public IMachiningChain GetMachiningChain() => MachineTool;
|
public IMachiningChain GetMachiningChain() => MachineTool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ public static class DemoBuildMachineToolWithoutGeometrys
|
|||||||
/// Generates an empty machine tool with basic configuration.
|
/// Generates an empty machine tool with basic configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A configured but empty machine tool without solids.</returns>
|
/// <returns>A configured but empty machine tool without solids.</returns>
|
||||||
public static CodeXyzabcMachineTool GenEmptyMachineTool()
|
public static GeneralXyzabcMachineTool GenEmptyMachineTool()
|
||||||
{
|
{
|
||||||
CodeXyzabcChain chain = new CodeXyzabcChain("[O][C][w];[O][X][Y][Z][B][S][t]");
|
GeneralXyzabcMachineTool xyzabcMachineTool = GeneralXyzabcMachineTool.CreateFromChainCode(
|
||||||
if (chain.ToolBuckleTransformer is StaticTranslation st)
|
"[O][C][w];[O][X][Y][Z][B][S][t]");
|
||||||
st.Trans = new Vec3d(-200, 200, 400);
|
if (xyzabcMachineTool.ToolMountTransformer is StaticTranslation st)
|
||||||
CodeXyzabcMachineTool xyzabcMachineTool = new CodeXyzabcMachineTool(chain);
|
st.Trans = new vec3d_t(-200, 200, 400);
|
||||||
return xyzabcMachineTool;
|
return xyzabcMachineTool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,23 +70,26 @@ public static class DemoBuildGeomOnlyMachiningProject
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
localProjectService.Fixture = new Fixture()
|
//The fixture topology is free; the default shape has one branch from the
|
||||||
{
|
//geometry anchor to each mount, so the workpiece mount is placed by the
|
||||||
Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)),
|
//transformer of the branch to it: on top of the 10 mm thick fixture geom.
|
||||||
GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)),
|
Fixture fixture = Fixture.CreateDefault();
|
||||||
};
|
fixture.Geom = new Box3d(new vec3d_t(-40, -40, 0), new vec3d_t(40, 40, 10));
|
||||||
|
Branch.Get(fixture.GeomAnchor, fixture.WorkpieceMount).Transformer
|
||||||
|
= new StaticTranslation(new vec3d_t(0, 0, 10));
|
||||||
|
localProjectService.Fixture = fixture;
|
||||||
|
|
||||||
localProjectService.Workpiece = new Workpiece()
|
//The default shape already leads from the geometry anchor to the fixture
|
||||||
{
|
//mount and to program zero by zero translations.
|
||||||
InitResolution = 0.25,
|
Workpiece workpiece = Workpiece.CreateDefault();
|
||||||
InitGeom = new Box3d(0, 0, -50, 70, 50, 0),
|
workpiece.InitResolution = 0.25;
|
||||||
IdealGeom = null,
|
workpiece.InitGeom = new Box3d(0, 0, -50, 70, 50, 0);
|
||||||
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)),
|
workpiece.IdealGeom = null;
|
||||||
};
|
localProjectService.Workpiece = workpiece;
|
||||||
|
|
||||||
IProgress<object> progress = null;
|
IProgress<object> progress = null;
|
||||||
localProjectService.MachiningChain
|
localProjectService.MachiningChain
|
||||||
= XFactory.GenByFile<CodeXyzabcMachineTool>(
|
= XFactory.GenByFile<GeneralXyzabcMachineTool>(
|
||||||
"Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress);
|
"Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress);
|
||||||
localProjectService.MachiningChainFile = "Table-B1.default/Table-B1.mt";
|
localProjectService.MachiningChainFile = "Table-B1.default/Table-B1.mt";
|
||||||
|
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ public static class DemoBuildMachiningProject
|
|||||||
InnerBeamProfile = new FluteDependentRatioProfile(),
|
InnerBeamProfile = new FluteDependentRatioProfile(),
|
||||||
MillingCutterOptLimit = new MillingCutterOptOption(),
|
MillingCutterOptLimit = new MillingCutterOptOption(),
|
||||||
};
|
};
|
||||||
//build FluteContourTray property
|
//build Fluting property
|
||||||
double helixAngle_deg = 50;
|
double helixAngle_deg = 50;
|
||||||
double radialRakeAngle_deg = 15;
|
double radialRakeAngle_deg = 15;
|
||||||
double bottomOuterRadius_mm = diameter_mm / 2 - roundRadius_mm;
|
double bottomOuterRadius_mm = diameter_mm / 2 - roundRadius_mm;
|
||||||
millingCutter.FluteContourTray = new UniformContourTray()
|
millingCutter.Fluting = new UniformFluting()
|
||||||
{
|
{
|
||||||
TrackNum = 3,
|
TrackNum = 3,
|
||||||
BaselineOneContour = new FluteContour()
|
BaselineOneContour = new FluteContour()
|
||||||
@@ -111,10 +111,10 @@ public static class DemoBuildMachiningProject
|
|||||||
MillingCutterOptLimit = new MillingCutterOptOption()
|
MillingCutterOptLimit = new MillingCutterOptOption()
|
||||||
};
|
};
|
||||||
|
|
||||||
//build FluteContourTray property
|
//build Fluting property
|
||||||
double helixAngle_deg = 50;
|
double helixAngle_deg = 50;
|
||||||
double radialRakeAngle_deg = 15;
|
double radialRakeAngle_deg = 15;
|
||||||
millingCutter.FluteContourTray = new UniformContourTray()
|
millingCutter.Fluting = new UniformFluting()
|
||||||
{
|
{
|
||||||
TrackNum = 3,
|
TrackNum = 3,
|
||||||
BaselineOneContour = new FluteContour()
|
BaselineOneContour = new FluteContour()
|
||||||
@@ -183,30 +183,33 @@ public static class DemoBuildMachiningProject
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ConfigureFixture
|
#region ConfigureFixture
|
||||||
localProjectService.Fixture = new Fixture()
|
//The fixture topology is free; the default shape has one branch from the
|
||||||
{
|
//geometry anchor to each mount, so the workpiece mount is placed by the
|
||||||
Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)),
|
//transformer of the branch to it: on top of the 10 mm thick fixture geom.
|
||||||
GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)),
|
Fixture fixture = Fixture.CreateDefault();
|
||||||
};
|
fixture.Geom = new Box3d(new vec3d_t(-40, -40, 0), new vec3d_t(40, 40, 10));
|
||||||
|
Branch.Get(fixture.GeomAnchor, fixture.WorkpieceMount).Transformer
|
||||||
|
= new StaticTranslation(new vec3d_t(0, 0, 10));
|
||||||
|
localProjectService.Fixture = fixture;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ConfigureWorkpiece
|
#region ConfigureWorkpiece
|
||||||
localProjectService.Workpiece = new Workpiece()
|
//The default shape already leads from the geometry anchor to the fixture
|
||||||
{
|
//mount and to program zero by zero translations.
|
||||||
InitResolution = 0.25,
|
Workpiece workpiece = Workpiece.CreateDefault();
|
||||||
InitGeom = new Box3d(0, 0, -50, 70, 50, 0),
|
workpiece.InitResolution = 0.25;
|
||||||
IdealGeom = null,
|
workpiece.InitGeom = new Box3d(0, 0, -50, 70, 50, 0);
|
||||||
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)),
|
workpiece.IdealGeom = null;
|
||||||
CuttingPara = XFactory.GenByFile<ICuttingPara>(
|
workpiece.CuttingPara = XFactory.GenByFile<ICuttingPara>(
|
||||||
"Resource/CuttingParameter", "Al6061T6.default.mp", progress),
|
"Resource/CuttingParameter", "Al6061T6.default.mp", progress);
|
||||||
WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>(
|
workpiece.WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>(
|
||||||
"Resource/WorkpieceMaterial", "Al6061T6.default.WorkpieceMaterial", progress),
|
"Resource/WorkpieceMaterial", "Al6061T6.default.WorkpieceMaterial", progress);
|
||||||
};
|
localProjectService.Workpiece = workpiece;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ConfigureMachineChain
|
#region ConfigureMachineChain
|
||||||
localProjectService.MachiningChain
|
localProjectService.MachiningChain
|
||||||
= XFactory.GenByFile<CodeXyzabcMachineTool>(
|
= XFactory.GenByFile<GeneralXyzabcMachineTool>(
|
||||||
"Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress);
|
"Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -33,10 +33,10 @@ public static class DemoTopo1
|
|||||||
Anchor B = new Anchor(asmb, "B");
|
Anchor B = new Anchor(asmb, "B");
|
||||||
|
|
||||||
//build kinematic link
|
//build kinematic link
|
||||||
Branch.Attach(O, O1, new StaticTranslation(new Vec3d(0, 0, 80)));
|
Branch.Attach(O, O1, new StaticTranslation(new vec3d_t(0, 0, 80)));
|
||||||
Branch brnX = Branch.Attach(O1, X, new DynamicTranslation(new Vec3d(1, 0, 0)));
|
Branch brnX = Branch.Attach(O1, X, new DynamicTranslation(new vec3d_t(1, 0, 0)));
|
||||||
Branch brnZ = Branch.Attach(X, Z, new DynamicTranslation(new Vec3d(0, 0, 1)));
|
Branch brnZ = Branch.Attach(X, Z, new DynamicTranslation(new vec3d_t(0, 0, 1)));
|
||||||
Branch brnB = Branch.Attach(Z, B, new DynamicRotation(new Vec3d(0, 1, 0), 0, new Vec3d(-100, 0, 0)));
|
Branch brnB = Branch.Attach(Z, B, new DynamicRotation(new vec3d_t(0, 1, 0), 0, new vec3d_t(-100, 0, 0)));
|
||||||
|
|
||||||
//drive the dynamic transformation by single value for each branch.
|
//drive the dynamic transformation by single value for each branch.
|
||||||
brnX.Step = 200;
|
brnX.Step = 200;
|
||||||
@@ -44,9 +44,9 @@ public static class DemoTopo1
|
|||||||
brnB.Step = MathUtil.ToRad(-60);
|
brnB.Step = MathUtil.ToRad(-60);
|
||||||
|
|
||||||
//Get and show the transform matrices relative to O.
|
//Get and show the transform matrices relative to O.
|
||||||
Dictionary<Anchor, Mat4d> matMap = asmb.GetMat4dMap(O);
|
Dictionary<Anchor, mat4d_t> matMap = asmb.GetMat4dMap(O);
|
||||||
Console.WriteLine("Transform Matrix relative to O:");
|
Console.WriteLine("Transform Matrix relative to O:");
|
||||||
foreach (KeyValuePair<Anchor, Mat4d> keyValue in matMap)
|
foreach (KeyValuePair<Anchor, mat4d_t> keyValue in matMap)
|
||||||
Console.WriteLine($"{keyValue.Key.Name} : {keyValue.Value}");
|
Console.WriteLine($"{keyValue.Key.Name} : {keyValue.Value}");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user