Skip to content

Commit d69843c

Browse files
committed
update
1 parent 6e79f09 commit d69843c

11 files changed

+6443
-6304
lines changed

Crystallography.Controls/Crystallography.Controls.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<OutputType>Library</OutputType>
55
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
7-
<AssemblyVersion>2024.8.10.0156</AssemblyVersion>
8-
<FileVersion>2024.8.10.0156</FileVersion>
7+
<AssemblyVersion>2024.8.23.0532</AssemblyVersion>
8+
<FileVersion>2024.8.23.0532</FileVersion>
99
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
1010
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
1111
<ApplicationVisualStyles>true</ApplicationVisualStyles>

Crystallography.OpenGL/Crystallography.OpenGL.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<OutputType>Library</OutputType>
55
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
7-
<AssemblyVersion>2024.8.10.0156</AssemblyVersion>
8-
<FileVersion>2024.8.10.0156</FileVersion>
7+
<AssemblyVersion>2024.8.23.0728</AssemblyVersion>
8+
<FileVersion>2024.8.23.0728</FileVersion>
99
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
1010
</PropertyGroup>
1111

Crystallography.OpenGL/GLObject.cs

+84-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
using M4f = OpenTK.Matrix4;
2222
using M3d = OpenTK.Matrix3d;
2323
using PT = OpenTK.Graphics.OpenGL4.PrimitiveType;
24+
using MathNet.Numerics.Distributions;
25+
using static System.Windows.Forms.DataFormats;
2426
#endregion 定義
2527

2628
namespace Crystallography.OpenGL;
@@ -693,7 +695,7 @@ public Lines(V3d[] vertices, float lineWidth, Material mat) : base(mat, DrawingM
693695
CircumscribedSphereRadius = vertices.Max(v => (v - center).Length);
694696
Vertices = vertices.Select(v => new Vertex(v.ToV3f(), mat.Argb)).ToArray();
695697
Indices = Enumerable.Range(0, vertices.Length).Select(i => (uint)i).ToArray();
696-
Primitives = new[] { (PT.LineStrip, vertices.Length) };
698+
Primitives = [(PT.LineStrip, vertices.Length)];
697699
}
698700
}
699701

@@ -868,7 +870,7 @@ static V3d[][] decompose(V3d[] srcVertex, int ord)
868870
/// <param name="c">頂点c</param>
869871
/// <param name="mat"></param>
870872
/// <param name="mode"></param>
871-
public class Triangle(V3d a, V3d b, V3d c, Material mat, DrawingMode mode) : Polygon(new V3d[] { a, b, c }, mat, mode)
873+
public class Triangle(V3d a, V3d b, V3d c, Material mat, DrawingMode mode) : Polygon([a, b, c], mat, mode)
872874
{
873875
public Triangle(Vector3DBase a, Vector3DBase b, Vector3DBase c, Material mat, DrawingMode mode)
874876
: this(new V3d(a.X, a.Y, a.Z), new V3d(b.X, b.Y, b.Z), new V3d(c.X, c.Y, c.Z), mat, mode) { }
@@ -915,6 +917,82 @@ public Disk(V3d origin, V3d normal, double radius, float lineWidth, Material mat
915917
{ LineWidth = lineWidth; }
916918
}
917919

920+
/// <summary>
921+
/// 穴あきディスク
922+
/// </summary>
923+
public class HoledDisk : GLObject
924+
{
925+
public double RadiusInner, RadiusOuter;
926+
927+
public V3d Origin, Normal;
928+
public HoledDisk(V3d origin, V3d normal, double radius1, double radius2, Material mat, DrawingMode mode, int slices = 60):base(mat,mode)
929+
{
930+
RadiusInner=Math.Min(radius1, radius2);
931+
RadiusOuter=Math.Max(radius1, radius2);
932+
Origin = origin;
933+
Normal = normal;
934+
935+
CircumscribedSphereCenter = new V4d(origin, 1);
936+
CircumscribedSphereRadius = RadiusOuter;
937+
938+
var sins = Enumerable.Range(0, slices).Select(i => Math.Sin((double)i / slices * 2 * Math.PI)).ToArray();
939+
var coss = Enumerable.Range(0, slices).Select(i => Math.Cos((double)i / slices * 2 * Math.PI)).ToArray();
940+
941+
IgnoreNormalSides = true;
942+
943+
M3d rotMat;
944+
if (normal == vZ)
945+
rotMat = M3d.Identity;
946+
else
947+
rotMat = M3d.CreateFromAxisAngle(V3d.Cross(normal, vZ), V3d.CalculateAngle(vZ, normal));
948+
949+
var vertices = new V3d[slices * 2];
950+
951+
for (int i = 0; i < slices; i++)
952+
{
953+
vertices[i] = new V3d(RadiusOuter * sins[i], RadiusOuter * coss[i], 0);
954+
vertices[i+slices] = new V3d(RadiusInner * sins[i], RadiusInner * coss[i], 0);
955+
}
956+
957+
List<int> indicesTmp = [];
958+
for (int i = 0; i < slices; i++)
959+
{
960+
if (i < slices - 1)
961+
indicesTmp.AddRange([i, i + 1, i + slices + 1, i + slices]);
962+
else
963+
indicesTmp.AddRange([i, 0, slices + 1, i + slices]);
964+
}
965+
var types = new List<PT>();
966+
var indices = new List<int[]>();
967+
968+
types.Add(PT.Quads);
969+
indices.Add([.. indicesTmp]);
970+
971+
types.Add(PT.LineLoop);
972+
indices.Add([.. indicesTmp]);
973+
974+
types.Add(PT.Points);
975+
indices.Add(Enumerable.Range(0, vertices.Length).ToArray());
976+
977+
Vertices = new Vertex[vertices.Length];
978+
for (int i = 0; i < vertices.Length; i++)
979+
Vertices[i] = new Vertex((rotMat.Mult(vertices[i]) + origin).ToV3f(), normal.ToV3f(), mat.Argb);
980+
981+
Indices = indices.SelectMany(i => i).Select(i => (uint)i).ToArray();
982+
983+
Primitives = types.Select((t, i) => (t, indices[i].Length)).ToArray();
984+
985+
986+
}
987+
988+
public HoledDisk(Vector3DBase origin, Vector3DBase normal, double radius1, double radius2, Material mat, DrawingMode mode, int slices = 60)
989+
: this(new V3d(origin.X, origin.Y, origin.Z), new V3d(normal.X, normal.Y, normal.Z), radius1, radius2, mat, mode, slices) { }
990+
991+
public HoledDisk(V3d origin, V3d normal, double radius1, double radius2, float lineWidth, Material mat, DrawingMode mode, int slices = 60)
992+
: this(origin, normal, radius1, radius2, mat, mode, slices)
993+
{ LineWidth = lineWidth; }
994+
}
995+
918996
#endregion
919997

920998
#region 多面体、立方体
@@ -1235,7 +1313,8 @@ public Pipe(in V3d o, in V3d vec, in double r1, in double r2, Material mat, Draw
12351313
/// <param name="vec">始点から終点へのベクトル</param>
12361314
/// <param name="r1">始点側の半径</param>
12371315
/// <param name="r2">終点側の半径</param>
1238-
/// <param name="mat">素材</param>
1316+
/// <param name="mat1">素材</param>
1317+
/// <param name="mat2">素材 (指定しない場合はmat1と同じ, 指定した場合は半分がこれになる)</param>
12391318
/// <param name="mode">描画モード</param>
12401319
/// <param name="sole">trueの場合は底面を描画する</param>
12411320
/// <param name="slices">高さの分割数</param>
@@ -1321,9 +1400,9 @@ public Pipe(in V3d o, in V3d vec, in double r1, in double r2, Material mat1, Mat
13211400
{
13221401
current = h * stacks + t;
13231402
if (t < stacks - 1)
1324-
indiceSide.AddRange(new[] { current, current + stacks, current + 1 + stacks, current + 1 });
1403+
indiceSide.AddRange([current, current + stacks, current + 1 + stacks, current + 1]);
13251404
else
1326-
indiceSide.AddRange(new[] { current, current + stacks, current + 1, current + 1 - stacks });
1405+
indiceSide.AddRange([current, current + stacks, current + 1, current + 1 - stacks]);
13271406
}
13281407
var types = new List<PT>();
13291408
var indices = new List<int[]>();

Crystallography/Crystallography.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<OutputType>Library</OutputType>
55
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
7-
<AssemblyVersion>2024.8.10.0156</AssemblyVersion>
8-
<FileVersion>2024.8.10.0156</FileVersion>
7+
<AssemblyVersion>2024.8.23.0532</AssemblyVersion>
8+
<FileVersion>2024.8.23.0532</FileVersion>
99
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
1010
</PropertyGroup>
1111

@@ -28,7 +28,7 @@
2828
<PackageReference Include="MemoryPack" Version="1.21.1" />
2929
<PackageReference Include="OpenTK" Version="3.3.3" />
3030
<PackageReference Include="SimdLinq" Version="1.3.2" />
31-
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.4" />
31+
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.5" />
3232
</ItemGroup>
3333

3434
<ItemGroup>

ReciPro/DiffractionSimulator/FormDiffractionSimulator.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,6 @@ private void checkBoxReciprocalSpace_CheckedChanged(object sender, EventArgs e)
29152915
private (double maxAngle, double ewaldRadius, bool Precession) beforeEwald = (0, 0, false);
29162916
private void Draw3D()
29172917
{
2918-
29192918
var r = EwaldRadius;
29202919
var ewaldCenter = new Vector3D(0, 0, r);
29212920

0 commit comments

Comments
 (0)